Update lndl version to 0.3.14 and make code improvements
This commit is contained in:
parent
d7b7e05a76
commit
56e5c0af80
@ -6,7 +6,7 @@ A python lib came from [Difficult Rocket](https://github.com/shenjackyuanjie/Dif
|
||||
|
||||
## Information/信息
|
||||
|
||||
- Version / 版本: 0.3.13
|
||||
- Version / 版本: 0.3.14
|
||||
- Author / 作者: shenjackyuanjie <3695888@qq.com>
|
||||
|
||||
[shenjackyuanjie](https://github.com/shenjackyuanjie)
|
||||
|
@ -1,5 +1,12 @@
|
||||
# lndl 0.3
|
||||
|
||||
## 0.3.14
|
||||
|
||||
- lndl-nuitka
|
||||
- 言出法随(
|
||||
- 为 arg_parse.py 添加了一些类型注释相关的内容
|
||||
- 好好好, 这就更新
|
||||
|
||||
## 0.3.13
|
||||
|
||||
- lndl-nuitka
|
||||
|
@ -9,7 +9,7 @@ from typing import TYPE_CHECKING
|
||||
if TYPE_CHECKING:
|
||||
from lib_not_dr import loggers, nuitka, types, command
|
||||
|
||||
_version_ = "0.3.13"
|
||||
_version_ = "0.3.14"
|
||||
|
||||
# fmt: off
|
||||
__all__ = [
|
||||
|
@ -39,7 +39,8 @@ def pyproject_toml(toml_data: dict) -> raw_config_type:
|
||||
|
||||
if "main" not in nuitka_config["cli"]:
|
||||
raise ValueError(
|
||||
"'main' not define in lib-not-dr(lndl).nuitka.cli section\ndefine it with 'main = [<main.py>]'"
|
||||
"'main' not define in lib-not-dr(lndl).nuitka.cli section\n"
|
||||
"define it with 'main = [<main.py>]'"
|
||||
)
|
||||
|
||||
return nuitka_config
|
||||
@ -107,7 +108,8 @@ def merge_cli_config(toml_config: dict, cli_config: dict) -> dict:
|
||||
for name, value in cli_config.items():
|
||||
if name in toml_config:
|
||||
warn(
|
||||
f"\033[33mcli config will overwrite toml config\n{name}:{toml_config[name]} -> {value}\033[0m"
|
||||
"\033[33mcli config will overwrite toml config\n"
|
||||
f"{name}:{toml_config[name]} -> {value}\033[0m"
|
||||
)
|
||||
if isinstance(toml_config[name], bool):
|
||||
if not isinstance(value, bool):
|
||||
@ -195,8 +197,11 @@ def parse_raw_config_by_script(raw_config: raw_config_type) -> nuitka_config_typ
|
||||
:param raw_config:
|
||||
:return: parsed config
|
||||
"""
|
||||
if (script_name := raw_config.get("script")) is None:
|
||||
return raw_config["cli"]
|
||||
raw_cli_config: nuitka_config_type = raw_config.get("cli", {}) # type: ignore
|
||||
|
||||
if (script_name := raw_config.get("script")) is None: # type: ignore
|
||||
return raw_cli_config
|
||||
script_name: str
|
||||
print(f'reading script {script_name}')
|
||||
script_path = Path(script_name)
|
||||
|
||||
@ -207,21 +212,22 @@ def parse_raw_config_by_script(raw_config: raw_config_type) -> nuitka_config_typ
|
||||
except Exception as e:
|
||||
print(f"script {script_path} import failed ignore it\n{e}")
|
||||
sys.path.remove(str(script_path.parent))
|
||||
return raw_config["cli"]
|
||||
return raw_cli_config
|
||||
|
||||
sys.path.remove(str(script_path.parent))
|
||||
|
||||
if not hasattr(script_module, "main"):
|
||||
print(f"script {script_path} has no paser function ignore it")
|
||||
return raw_config["cli"]
|
||||
return raw_cli_config
|
||||
|
||||
parse_func: parse_config_function = getattr(script_module, "main")
|
||||
try:
|
||||
parsed_config = script_module.main(raw_config)
|
||||
parsed_config = parse_func(raw_config)
|
||||
except Exception as e:
|
||||
print(f"script {script_path} parse failed ignore it")
|
||||
print(e)
|
||||
traceback.print_exc()
|
||||
return raw_config["cli"]
|
||||
return raw_cli_config
|
||||
|
||||
return parsed_config
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user