diff --git a/.gitignore b/.gitignore index 2edaf21..51334e1 100644 --- a/.gitignore +++ b/.gitignore @@ -146,3 +146,6 @@ dmypy.json # Cython debug symbols cython_debug/ + +# Pycharm +.idea/ diff --git a/llc_cli.py b/llc_cli.py index 09931bb..799e61c 100644 --- a/llc_cli.py +++ b/llc_cli.py @@ -24,10 +24,10 @@ import sys print("小贴:不妨试试Mid-BDX转换网页:在线的多功能Midi转换器") print("https://dislink.github.io/midi2bdx/") - import Musicreater -from utils.io import * +# 这一句可以不要,因为lang里面已经有了 +# from utils.io import * from languages.lang import * MainConsole.print( @@ -36,30 +36,29 @@ MainConsole.print( justify="center", ) - - osc.project_name = "伶伦" osc.version = __version__ def go_for_args( - languageChange: str = "ZH-CN", debugMode: str = 'False', logfile: str = 'True' + languageChange: str = "ZH-CN", debugMode: str = "False", logfile: str = "True" ): global currentLang global logger currentLang = ( languageChange.upper() if languageChange.upper() in languages.keys() - else 'ZH-CN' + else "ZH-CN" ) - osc.isRelease = False if debugMode.lower() in ("true", '1') else True - logger.printing=not osc.isRelease - logger.writing=True if logfile.lower() in ("true", '1') else False - + osc.isRelease = False if debugMode.lower() in ("true", "1") else True + logger.printing = not osc.isRelease + logger.writing = True if logfile.lower() in ("true", "1") else False + if len(sys.argv) > 0: go_for_args(*sys.argv) + def _(__): """ `languages` @@ -76,7 +75,7 @@ nowYang = datetime.datetime.now() if nowYang.month == 8 and nowYang.day == 6: # 诸葛八卦生日 MainConsole.print( - "[#7DB5F0 on #121110]今天可不是催更的日子!\n诸葛亮与八卦阵{}岁生日快乐!".format(nowYang.year - 2009), + "[#7DB5F0 on #121110]今天可不是催更的日子!\n诸葛亮与八卦阵{}岁生日快乐!".format(nowYang.year - 2008), style="#7DB5F0 on #121110", justify="center", ) @@ -91,15 +90,11 @@ else: # 显示箴言部分 try: MainConsole.print( - "[#121110 on #F0F2F4]{}".format( - random.choice( - myWords - ) - ), + "[#121110 on #F0F2F4]{}".format(random.choice(myWords)), style="#121110 on #F0F2F4", justify="center", ) - except (ConnectionError,SSLError): + except (ConnectionError, SSLError): MainConsole.print( "[#121110 on #F0F2F4]以梦想为驱使 创造属于自己的未来", style="#121110 on #F0F2F4", diff --git a/requirements.txt b/requirements.txt index 50bcfbd..40f008e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ Brotli>=1.0.9 mido>=1.2.10 Musicreater>=0.1.0 -TrimLog>=0.1.0 \ No newline at end of file +TrimLog>=0.1.0 +requests>=2.25.1 diff --git a/utils/io.py b/utils/io.py index fc0eaf6..a89690e 100644 --- a/utils/io.py +++ b/utils/io.py @@ -1,5 +1,3 @@ - - from typing import Any, Literal, Optional, TextIO import requests @@ -12,11 +10,22 @@ osc = object_constants.ObjectStateConstant() logger = TrimLog.Logger( is_logging=True, printing=not osc.isRelease, - in_suffix='.llc', + in_suffix=".llc", ) -myWords = requests.get( - "https://gitee.com/TriM-Organization/LinglunStudio/raw/master/resources/myWords.txt" -).text.strip("\n").split("\n") + +try: + myWords = ( + requests.get( + "https://gitee.com/TriM-Organization/LinglunStudio/raw/master/resources/myWords.txt" + ) + .text.strip("\n") + .split("\n") + ) +except (ConnectionError, SSLError): + myWords = "以梦想为驱使 创造属于自己的未来" +# noinspection PyBroadException +except BaseException: + myWords = "以梦想为驱使 创造属于自己的未来" JustifyMethod = Literal["default", "left", "center", "right", "full"] @@ -157,7 +166,8 @@ def format_ipt( try: fun_result = fun(result, *extraArg) break - except: + # noinspection PyBroadException + except BaseException: prt(err_note) continue return result, fun_result