From f6a5645b18a1dc5dec2bb53d4563d5dd1e3adbf4 Mon Sep 17 00:00:00 2001 From: NewLife1324 <61694357+NewLife1324@users.noreply.github.com> Date: Sun, 31 Jan 2021 16:12:34 +0300 Subject: [PATCH] Reformat --- NewLifeUtils/CustomShellModule.py | 60 +- NewLifeUtils/ExceptModule.py | 4 +- NewLifeUtils/FileModule.py | 4 +- NewLifeUtils/LoggerModule.py | 905 ++++++------------------------ NewLifeUtils/StringUtilModule.py | 6 +- NewLifeUtils/TableBuildModule.py | 32 +- NewLifeUtils/UtilsModule.py | 20 +- 7 files changed, 234 insertions(+), 797 deletions(-) diff --git a/NewLifeUtils/CustomShellModule.py b/NewLifeUtils/CustomShellModule.py index e4f9006..25813c2 100644 --- a/NewLifeUtils/CustomShellModule.py +++ b/NewLifeUtils/CustomShellModule.py @@ -21,8 +21,8 @@ "same_command": [ "Console commands with the same names were registered.", "Here is a list of registered console commands (their names):", - "{list}" - ] + "{list}", + ], } create_config("shell_translation", "lang.yml", "shell", default_translation) @@ -31,9 +31,9 @@ class Shell(object): def __init__( - self, - name=translation.default_cmd_name, - about=translation.default_cmd_description, + self, + name=translation.default_cmd_name, + about=translation.default_cmd_description, ): self.run_state = "init" self.cmdname = name @@ -57,9 +57,7 @@ def __init__( new_rea_pattern="{cyan}[{time}] {lightcyan}{tag}{snow} : {mediumslateblue}{readed}", ) - @self.register_command( - "exit", ["quit"], translation.exit_description, [], [] - ) + @self.register_command("exit", ["quit"], translation.exit_description, [], []) def exit_(console): console.run_state = "quit" @@ -105,10 +103,10 @@ class CLR: f'{CLR.SOPT}[{"] [".join(command["optional"])}]{CLR.R} ' ) helpPage += ( - f'\t{CLR.CMD}{command["command"]}\n' - + f'\t\t{CLR.CMDDSK}Description {CLR.R}: {CLR.CMDDSK}{command["description"]}\n' - + f'\t\t{CLR.ALS}Aliases {CLR.R}: {CLR.ALSTXT}{", ".join(command["aliases"])}\n' - + f"\t\t{CLR.STTL}Usage {CLR.R}: {syntax}{CLR.R}\n" + f'\t{CLR.CMD}{command["command"]}\n' + + f'\t\t{CLR.CMDDSK}Description {CLR.R}: {CLR.CMDDSK}{command["description"]}\n' + + f'\t\t{CLR.ALS}Aliases {CLR.R}: {CLR.ALSTXT}{", ".join(command["aliases"])}\n' + + f"\t\t{CLR.STTL}Usage {CLR.R}: {syntax}{CLR.R}\n" ) tip(helpPage, f"{console.cmdname} HELP") elif console.paramCount == 1: @@ -128,10 +126,10 @@ class CLR: if command["optional"]: syntax += f'{CLR.SOPT}[{"] [".join(command["optional"])}]{CLR.R} ' helpPage += ( - f'\t{CLR.CMD}{command["command"]}\n' - + f'\t\t{CLR.CMDDSK}Description: {command["description"]}\n' - + f'\t\t{CLR.ALS}Aliases: {CLR.ALSTXT}{", ".join(command["aliases"])}\n' - + f"\t\t{CLR.CMDDSK}Usage: {syntax}{CLR.R}\n" + f'\t{CLR.CMD}{command["command"]}\n' + + f'\t\t{CLR.CMDDSK}Description: {command["description"]}\n' + + f'\t\t{CLR.ALS}Aliases: {CLR.ALSTXT}{", ".join(command["aliases"])}\n' + + f"\t\t{CLR.CMDDSK}Usage: {syntax}{CLR.R}\n" ) tip(helpPage, f"{console.cmdname} HELP") finded = True @@ -227,13 +225,13 @@ def unregister_by_name(self, name): wrn(f"You can't get rid of the {name} command") def register_command( - self, - command, - aliases=[], - description="my simple command", - required=[], - optional=["param"], - skipcheck=False, + self, + command, + aliases=[], + description="my simple command", + required=[], + optional=["param"], + skipcheck=False, ): def register_from_decorator(command_function): self.registered_commands.append( @@ -309,15 +307,15 @@ def insert_print(self, type, text, tag=""): def check_params(self): return ( - not ( - self.paramCount - > ( - len(self.current_executing["required"]) - + len(self.current_executing["optional"]) - ) - or self.paramCount < len(self.current_executing["required"]) + not ( + self.paramCount + > ( + len(self.current_executing["required"]) + + len(self.current_executing["optional"]) ) - or self.current_executing["skipcheck"] + or self.paramCount < len(self.current_executing["required"]) + ) + or self.current_executing["skipcheck"] ) def run(self): diff --git a/NewLifeUtils/ExceptModule.py b/NewLifeUtils/ExceptModule.py index b4b1232..5c471cd 100644 --- a/NewLifeUtils/ExceptModule.py +++ b/NewLifeUtils/ExceptModule.py @@ -13,7 +13,7 @@ "warning": "Warn", "error": "Error", "fatal": "Fatal error", - "wrong": "Something wrong..." + "wrong": "Something wrong...", } create_config("except_translation", "lang.yml", "exceptsettings", default_lang) translation = get_pointyaml("except_translation") @@ -24,7 +24,7 @@ def except_print(exception, exception_type="err", tb=True): error_text += f"{translation.type}: {type(exception).__name__}\n\n" if exception.args == 0: - error_text += f'{translation.unknown}\n' + error_text += f"{translation.unknown}\n" else: error_text += ( f'{translation["about"]}:\n\t{(chr(10) + chr(9)).join(exception.args)}\t\n' diff --git a/NewLifeUtils/FileModule.py b/NewLifeUtils/FileModule.py index e6a4e3d..bad5507 100644 --- a/NewLifeUtils/FileModule.py +++ b/NewLifeUtils/FileModule.py @@ -36,9 +36,7 @@ def create_config(alias, filename, folderpath, default_obj={}): create_dirs(directory) if not os.path.exists(os.path.join(directory, filename)) or rawread(alias) == "": f = open(os.path.join(directory, filename), "w") - yaml_write = yaml.dump( - default_obj, - default_flow_style=False) + yaml_write = yaml.dump(default_obj, default_flow_style=False) file_rewrite(alias, yaml_write) return False diff --git a/NewLifeUtils/LoggerModule.py b/NewLifeUtils/LoggerModule.py index dbfa593..8a92d1f 100644 --- a/NewLifeUtils/LoggerModule.py +++ b/NewLifeUtils/LoggerModule.py @@ -6,711 +6,147 @@ from NewLifeUtils.StringUtilModule import screate, remove_csi default_colors = { - "indianred": [ - 205, - 92, - 92 - ], - "lightcoral": [ - 240, - 128, - 128 - ], - "salmon": [ - 250, - 128, - 114 - ], - "darksalmon": [ - 233, - 150, - 122 - ], - "lightsalmon": [ - 255, - 160, - 122 - ], - "crimson": [ - 220, - 20, - 60 - ], - "red": [ - 255, - 0, - 0 - ], - "firebrick": [ - 178, - 34, - 34 - ], - "darkred": [ - 139, - 0, - 0 - ], - "pink": [ - 255, - 192, - 203 - ], - "lightpink": [ - 255, - 182, - 193 - ], - "hotpink": [ - 255, - 105, - 180 - ], - "deeppink": [ - 255, - 20, - 147 - ], - "mediumvioletred": [ - 199, - 21, - 133 - ], - "palevioletred": [ - 219, - 112, - 147 - ], - "coral": [ - 255, - 127, - 80 - ], - "tomato": [ - 255, - 99, - 71 - ], - "orangered": [ - 255, - 69, - 0 - ], - "darkorange": [ - 255, - 140, - 0 - ], - "orange": [ - 255, - 165, - 0 - ], - "gold": [ - 255, - 215, - 0 - ], - "yellow": [ - 255, - 255, - 0 - ], - "lightyellow": [ - 255, - 255, - 224 - ], - "lemonchiffon": [ - 255, - 250, - 205 - ], - "lightgoldenrodyellow": [ - 250, - 250, - 210 - ], - "papayawhip": [ - 255, - 239, - 213 - ], - "moccasin": [ - 255, - 228, - 181 - ], - "peachpuff": [ - 255, - 218, - 185 - ], - "palegoldenrod": [ - 238, - 232, - 170 - ], - "khaki": [ - 240, - 230, - 140 - ], - "darkkhaki": [ - 189, - 183, - 107 - ], - "lavender": [ - 230, - 230, - 250 - ], - "thistle": [ - 216, - 191, - 216 - ], - "plum": [ - 221, - 160, - 221 - ], - "violet": [ - 238, - 130, - 238 - ], - "orchid": [ - 218, - 112, - 214 - ], - "fuchsia": [ - 255, - 0, - 255 - ], - "magenta": [ - 255, - 0, - 255 - ], - "mediumorchid": [ - 186, - 85, - 211 - ], - "mediumpurple": [ - 147, - 112, - 219 - ], - "blueviolet": [ - 138, - 43, - 226 - ], - "darkviolet": [ - 148, - 0, - 211 - ], - "darkorchid": [ - 153, - 50, - 204 - ], - "darkmagenta": [ - 139, - 0, - 139 - ], - "purple": [ - 128, - 0, - 128 - ], - "indigo": [ - 75, - 0, - 130 - ], - "slateblue": [ - 106, - 90, - 205 - ], - "darkslateblue": [ - 72, - 61, - 139 - ], - "cornsilk": [ - 255, - 248, - 220 - ], - "blanchedalmond": [ - 255, - 235, - 205 - ], - "bisque": [ - 255, - 228, - 196 - ], - "navajowhite": [ - 255, - 222, - 173 - ], - "wheat": [ - 245, - 222, - 179 - ], - "burlywood": [ - 222, - 184, - 135 - ], - "tan": [ - 210, - 180, - 140 - ], - "rosybrown": [ - 188, - 143, - 143 - ], - "sandybrown": [ - 244, - 164, - 96 - ], - "goldenrod": [ - 218, - 165, - 32 - ], - "darkgoldenrod": [ - 184, - 134, - 11 - ], - "peru": [ - 205, - 133, - 63 - ], - "chocolate": [ - 210, - 105, - 30 - ], - "saddlebrown": [ - 139, - 69, - 19 - ], - "sienna": [ - 160, - 82, - 45 - ], - "brown": [ - 165, - 42, - 42 - ], - "maroon": [ - 128, - 0, - 0 - ], - "black": [ - 0, - 0, - 0 - ], - "gray": [ - 128, - 128, - 128 - ], - "silver": [ - 192, - 192, - 192 - ], - "white": [ - 255, - 255, - 255 - ], - "olive": [ - 128, - 128, - 0 - ], - "lime": [ - 0, - 255, - 0 - ], - "green": [ - 0, - 128, - 0 - ], - "aqua": [ - 0, - 255, - 255 - ], - "teal": [ - 0, - 128, - 128 - ], - "blue": [ - 0, - 0, - 255 - ], - "navy": [ - 0, - 0, - 128 - ], - "greenyellow": [ - 173, - 255, - 47 - ], - "chartreuse": [ - 127, - 255, - 0 - ], - "lawngreen": [ - 124, - 252, - 0 - ], - "limegreen": [ - 50, - 205, - 50 - ], - "palegreen": [ - 152, - 251, - 152 - ], - "lightgreen": [ - 144, - 238, - 144 - ], - "mediumspringgreen": [ - 0, - 250, - 154 - ], - "springgreen": [ - 0, - 255, - 127 - ], - "mediumseagreen": [ - 60, - 179, - 113 - ], - "seagreen": [ - 46, - 139, - 87 - ], - "forestgreen": [ - 34, - 139, - 34 - ], - "darkgreen": [ - 0, - 100, - 0 - ], - "yellowgreen": [ - 154, - 205, - 50 - ], - "olivedrab": [ - 107, - 142, - 35 - ], - "darkolivegreen": [ - 85, - 107, - 47 - ], - "mediumaquamarine": [ - 102, - 205, - 170 - ], - "darkseagreen": [ - 143, - 188, - 143 - ], - "lightseagreen": [ - 32, - 178, - 170 - ], - "darkcyan": [ - 0, - 139, - 139 - ], - "cyan": [ - 0, - 255, - 255 - ], - "lightcyan": [ - 224, - 255, - 255 - ], - "paleturquoise": [ - 175, - 238, - 238 - ], - "aquamarine": [ - 127, - 255, - 212 - ], - "turquoise": [ - 64, - 224, - 208 - ], - "mediumturquoise": [ - 72, - 209, - 204 - ], - "darkturquoise": [ - 0, - 206, - 209 - ], - "cadetblue": [ - 95, - 158, - 160 - ], - "steelblue": [ - 70, - 130, - 180 - ], - "lightsteelblue": [ - 176, - 196, - 222 - ], - "powderblue": [ - 176, - 224, - 230 - ], - "lightblue": [ - 173, - 216, - 230 - ], - "skyblue": [ - 135, - 206, - 235 - ], - "lightskyblue": [ - 135, - 206, - 250 - ], - "deepskyblue": [ - 0, - 191, - 255 - ], - "dodgerblue": [ - 30, - 144, - 255 - ], - "cornflowerblue": [ - 100, - 149, - 237 - ], - "mediumslateblue": [ - 123, - 104, - 238 - ], - "royalblue": [ - 65, - 105, - 225 - ], - "mediumblue": [ - 0, - 0, - 205 - ], - "darkblue": [ - 0, - 0, - 139 - ], - "midnightblue": [ - 25, - 25, - 112 - ], - "snow": [ - 255, - 250, - 250 - ], - "honeydew": [ - 240, - 255, - 240 - ], - "mintcream": [ - 245, - 255, - 250 - ], - "azure": [ - 240, - 255, - 255 - ], - "aliceblue": [ - 240, - 248, - 255 - ], - "ghostwhite": [ - 248, - 248, - 255 - ], - "whitesmoke": [ - 245, - 245, - 245 - ], - "seashell": [ - 255, - 245, - 238 - ], - "beige": [ - 245, - 245, - 220 - ], - "oldlace": [ - 253, - 245, - 230 - ], - "floralwhite": [ - 255, - 250, - 240 - ], - "ivory": [ - 255, - 255, - 240 - ], - "antiquewhite": [ - 250, - 235, - 215 - ], - "linen": [ - 250, - 240, - 230 - ], - "lavenderblush": [ - 255, - 240, - 245 - ], - "mistyrose": [ - 255, - 228, - 225 - ], - "gainsboro": [ - 220, - 220, - 220 - ], - "lightgrey": [ - 211, - 211, - 211 - ], - "darkgrey": [ - 169, - 169, - 169 - ], - "grey": [ - 128, - 128, - 128 - ], - "dimgrey": [ - 105, - 105, - 105 - ], - "lightslategrey": [ - 119, - 136, - 153 - ], - "slategrey": [ - 112, - 128, - 144 - ], - "darkslategrey": [ - "47p", - 79, - 79 - ] + "indianred": [205, 92, 92], + "lightcoral": [240, 128, 128], + "salmon": [250, 128, 114], + "darksalmon": [233, 150, 122], + "lightsalmon": [255, 160, 122], + "crimson": [220, 20, 60], + "red": [255, 0, 0], + "firebrick": [178, 34, 34], + "darkred": [139, 0, 0], + "pink": [255, 192, 203], + "lightpink": [255, 182, 193], + "hotpink": [255, 105, 180], + "deeppink": [255, 20, 147], + "mediumvioletred": [199, 21, 133], + "palevioletred": [219, 112, 147], + "coral": [255, 127, 80], + "tomato": [255, 99, 71], + "orangered": [255, 69, 0], + "darkorange": [255, 140, 0], + "orange": [255, 165, 0], + "gold": [255, 215, 0], + "yellow": [255, 255, 0], + "lightyellow": [255, 255, 224], + "lemonchiffon": [255, 250, 205], + "lightgoldenrodyellow": [250, 250, 210], + "papayawhip": [255, 239, 213], + "moccasin": [255, 228, 181], + "peachpuff": [255, 218, 185], + "palegoldenrod": [238, 232, 170], + "khaki": [240, 230, 140], + "darkkhaki": [189, 183, 107], + "lavender": [230, 230, 250], + "thistle": [216, 191, 216], + "plum": [221, 160, 221], + "violet": [238, 130, 238], + "orchid": [218, 112, 214], + "fuchsia": [255, 0, 255], + "magenta": [255, 0, 255], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "blueviolet": [138, 43, 226], + "darkviolet": [148, 0, 211], + "darkorchid": [153, 50, 204], + "darkmagenta": [139, 0, 139], + "purple": [128, 0, 128], + "indigo": [75, 0, 130], + "slateblue": [106, 90, 205], + "darkslateblue": [72, 61, 139], + "cornsilk": [255, 248, 220], + "blanchedalmond": [255, 235, 205], + "bisque": [255, 228, 196], + "navajowhite": [255, 222, 173], + "wheat": [245, 222, 179], + "burlywood": [222, 184, 135], + "tan": [210, 180, 140], + "rosybrown": [188, 143, 143], + "sandybrown": [244, 164, 96], + "goldenrod": [218, 165, 32], + "darkgoldenrod": [184, 134, 11], + "peru": [205, 133, 63], + "chocolate": [210, 105, 30], + "saddlebrown": [139, 69, 19], + "sienna": [160, 82, 45], + "brown": [165, 42, 42], + "maroon": [128, 0, 0], + "black": [0, 0, 0], + "gray": [128, 128, 128], + "silver": [192, 192, 192], + "white": [255, 255, 255], + "olive": [128, 128, 0], + "lime": [0, 255, 0], + "green": [0, 128, 0], + "aqua": [0, 255, 255], + "teal": [0, 128, 128], + "blue": [0, 0, 255], + "navy": [0, 0, 128], + "greenyellow": [173, 255, 47], + "chartreuse": [127, 255, 0], + "lawngreen": [124, 252, 0], + "limegreen": [50, 205, 50], + "palegreen": [152, 251, 152], + "lightgreen": [144, 238, 144], + "mediumspringgreen": [0, 250, 154], + "springgreen": [0, 255, 127], + "mediumseagreen": [60, 179, 113], + "seagreen": [46, 139, 87], + "forestgreen": [34, 139, 34], + "darkgreen": [0, 100, 0], + "yellowgreen": [154, 205, 50], + "olivedrab": [107, 142, 35], + "darkolivegreen": [85, 107, 47], + "mediumaquamarine": [102, 205, 170], + "darkseagreen": [143, 188, 143], + "lightseagreen": [32, 178, 170], + "darkcyan": [0, 139, 139], + "cyan": [0, 255, 255], + "lightcyan": [224, 255, 255], + "paleturquoise": [175, 238, 238], + "aquamarine": [127, 255, 212], + "turquoise": [64, 224, 208], + "mediumturquoise": [72, 209, 204], + "darkturquoise": [0, 206, 209], + "cadetblue": [95, 158, 160], + "steelblue": [70, 130, 180], + "lightsteelblue": [176, 196, 222], + "powderblue": [176, 224, 230], + "lightblue": [173, 216, 230], + "skyblue": [135, 206, 235], + "lightskyblue": [135, 206, 250], + "deepskyblue": [0, 191, 255], + "dodgerblue": [30, 144, 255], + "cornflowerblue": [100, 149, 237], + "mediumslateblue": [123, 104, 238], + "royalblue": [65, 105, 225], + "mediumblue": [0, 0, 205], + "darkblue": [0, 0, 139], + "midnightblue": [25, 25, 112], + "snow": [255, 250, 250], + "honeydew": [240, 255, 240], + "mintcream": [245, 255, 250], + "azure": [240, 255, 255], + "aliceblue": [240, 248, 255], + "ghostwhite": [248, 248, 255], + "whitesmoke": [245, 245, 245], + "seashell": [255, 245, 238], + "beige": [245, 245, 220], + "oldlace": [253, 245, 230], + "floralwhite": [255, 250, 240], + "ivory": [255, 255, 240], + "antiquewhite": [250, 235, 215], + "linen": [250, 240, 230], + "lavenderblush": [255, 240, 245], + "mistyrose": [255, 228, 225], + "gainsboro": [220, 220, 220], + "lightgrey": [211, 211, 211], + "darkgrey": [169, 169, 169], + "grey": [128, 128, 128], + "dimgrey": [105, 105, 105], + "lightslategrey": [119, 136, 153], + "slategrey": [112, 128, 144], + "darkslategrey": ["47p", 79, 79], } default_colors2 = { @@ -1064,7 +500,7 @@ "lavender_blue": "#E3E4FA", "pearl": "#FDEEF4", "seashell": "#FFF5EE", - "milk_white": "#FEFCFF" + "milk_white": "#FEFCFF", } default_config = { @@ -1084,7 +520,7 @@ "colormap": 1, "file_log": True, "logtime": "%d-%m-%Y_%H-%M", - "logname": "log_{time}" + "logname": "log_{time}", } create_config("logger_colors", "color_schema.yml", "logger", default_colors) @@ -1115,7 +551,7 @@ settings_color2 = get_pointyaml("logger_colors2") for color in settings_color2: h = settings_color2[color].lstrip("#") - colormap[color] = tuple(int(h[i: i + 2], 16) for i in (0, 2, 4)) + colormap[color] = tuple(int(h[i : i + 2], 16) for i in (0, 2, 4)) else: settings_color1 = get_pointyaml("logger_colors") for color in settings_color1: @@ -1123,22 +559,22 @@ def set_settings( - new_log_pattern=log_pattern, - new_wrn_pattern=wrn_pattern, - new_err_pattern=err_pattern, - new_tip_pattern=tip_pattern, - new_rea_pattern=rea_pattern, - new_log_default_tag=log_default_tag, - new_wrn_default_tag=wrn_default_tag, - new_err_default_tag=err_default_tag, - new_tip_default_tag=tip_default_tag, - new_rea_default_tag=rea_default_tag, - new_date_format=date_format, - new_time_format=time_format, - new_tag_length=tag_length, - new_enable_file_fog=enable_file_fog, - new_logtime=logtime, - new_logname=logname, + new_log_pattern=log_pattern, + new_wrn_pattern=wrn_pattern, + new_err_pattern=err_pattern, + new_tip_pattern=tip_pattern, + new_rea_pattern=rea_pattern, + new_log_default_tag=log_default_tag, + new_wrn_default_tag=wrn_default_tag, + new_err_default_tag=err_default_tag, + new_tip_default_tag=tip_default_tag, + new_rea_default_tag=rea_default_tag, + new_date_format=date_format, + new_time_format=time_format, + new_tag_length=tag_length, + new_enable_file_fog=enable_file_fog, + new_logtime=logtime, + new_logname=logname, ): global log_pattern global wrn_pattern @@ -1186,15 +622,15 @@ def to_format(pattern, args): now = datetime.datetime.now() return ( - ACC.RESET + - MCC.ERASE_ALL_LINE - + pattern.format( - **args, - **colormap, - date=now.strftime(date_format), - time=now.strftime(time_format), - ) - + ACC.RESET + ACC.RESET + + MCC.ERASE_ALL_LINE + + pattern.format( + **args, + **colormap, + date=now.strftime(date_format), + time=now.strftime(time_format), + ) + + ACC.RESET ) @@ -1242,7 +678,8 @@ def tip(message, tag=""): to_format( tip_pattern, {"message": message, "tag": tag_check(tag, tip_default_tag)}, - )) + ) + ) def cstm(pattern, args): diff --git a/NewLifeUtils/StringUtilModule.py b/NewLifeUtils/StringUtilModule.py index 7d6671d..9f1d35b 100644 --- a/NewLifeUtils/StringUtilModule.py +++ b/NewLifeUtils/StringUtilModule.py @@ -13,8 +13,8 @@ def remove_csi(text): "", text.encode("unicode_escape").decode(), ) - .encode() - .decode("unicode_escape") + .encode() + .decode("unicode_escape") ) @@ -44,7 +44,7 @@ def sslice(text, chunk_size): chunk_size: """ text = str(text) - return [text[i: i + chunk_size] for i in range(0, len(text), chunk_size)] + return [text[i : i + chunk_size] for i in range(0, len(text), chunk_size)] def parse_args(readed): diff --git a/NewLifeUtils/TableBuildModule.py b/NewLifeUtils/TableBuildModule.py index 9e28af1..4531236 100644 --- a/NewLifeUtils/TableBuildModule.py +++ b/NewLifeUtils/TableBuildModule.py @@ -32,14 +32,14 @@ def find_max(row_count, data): def create_table( - row_count, - sizes, - data, - title="TABLE", - header=True, - table_element="", - color="", - align="l", + row_count, + sizes, + data, + title="TABLE", + header=True, + table_element="", + color="", + align="l", ): if not sizes: sizes = find_max(row_count, data) @@ -101,13 +101,13 @@ def create_table( def create_multiline_table( - row_count, - sizes, - data, - title="TABLE", - table_element="", - color="", - align="l", + row_count, + sizes, + data, + title="TABLE", + table_element="", + color="", + align="l", ): if not sizes: sizes = find_max(row_count, data) @@ -219,7 +219,7 @@ def join_column(columns): def get_record(row_count, data, record_id): - return data[row_count * record_id: row_count * record_id + row_count] + return data[row_count * record_id : row_count * record_id + row_count] def get_record_count(row_count, data): diff --git a/NewLifeUtils/UtilsModule.py b/NewLifeUtils/UtilsModule.py index 302c281..05947bf 100644 --- a/NewLifeUtils/UtilsModule.py +++ b/NewLifeUtils/UtilsModule.py @@ -78,8 +78,8 @@ def bprint(text, maxlinelength=9, font="default"): def format_number( - number=random.randrange(1111111111111111, 9999999999999999), - numform="4444", + number=random.randrange(1111111111111111, 9999999999999999), + numform="4444", ): # A total conversion number = int(number) @@ -103,7 +103,7 @@ def format_number( result = str(number) shift = 0 for pos in numform: - result = result[: int(pos) + shift] + " " + result[int(pos) + shift:] + result = result[: int(pos) + shift] + " " + result[int(pos) + shift :] shift += int(pos) + 1 return result @@ -133,11 +133,15 @@ def hex_to_rgb(hx, hsl=False): Tuple of length 3 consisting of either int or float values. Raise: ValueError: If given value is not a valid HEX code.""" - if re.compile(r'#[a-fA-F0-9]{3}(?:[a-fA-F0-9]{3})?$').match(hx): + if re.compile(r"#[a-fA-F0-9]{3}(?:[a-fA-F0-9]{3})?$").match(hx): div = 255.0 if hsl else 0 if len(hx) <= 4: - return tuple(int(hx[i] * 2, 16) / div if div else - int(hx[i] * 2, 16) for i in (1, 2, 3)) - return tuple(int(hx[i:i + 2], 16) / div if div else - int(hx[i:i + 2], 16) for i in (1, 3, 5)) + return tuple( + int(hx[i] * 2, 16) / div if div else int(hx[i] * 2, 16) + for i in (1, 2, 3) + ) + return tuple( + int(hx[i : i + 2], 16) / div if div else int(hx[i : i + 2], 16) + for i in (1, 3, 5) + ) raise ValueError(f'"{hx}" is not a valid HEX code.')