Compare commits
3 Commits
716f735fe7
...
56e5c0af80
Author | SHA1 | Date | |
---|---|---|---|
56e5c0af80 | |||
d7b7e05a76 | |||
8baf2d4d70 |
@ -6,7 +6,7 @@ A python lib came from [Difficult Rocket](https://github.com/shenjackyuanjie/Dif
|
|||||||
|
|
||||||
## Information/信息
|
## Information/信息
|
||||||
|
|
||||||
- Version / 版本: 0.3.12
|
- Version / 版本: 0.3.14
|
||||||
- Author / 作者: shenjackyuanjie <3695888@qq.com>
|
- Author / 作者: shenjackyuanjie <3695888@qq.com>
|
||||||
|
|
||||||
[shenjackyuanjie](https://github.com/shenjackyuanjie)
|
[shenjackyuanjie](https://github.com/shenjackyuanjie)
|
||||||
|
@ -1,5 +1,23 @@
|
|||||||
# lndl 0.3
|
# lndl 0.3
|
||||||
|
|
||||||
|
## 0.3.14
|
||||||
|
|
||||||
|
- lndl-nuitka
|
||||||
|
- 言出法随(
|
||||||
|
- 为 arg_parse.py 添加了一些类型注释相关的内容
|
||||||
|
- 好好好, 这就更新
|
||||||
|
|
||||||
|
## 0.3.13
|
||||||
|
|
||||||
|
- lndl-nuitka
|
||||||
|
- 大概是最后一次 0.3 的更新了
|
||||||
|
- 修复了带有 `__spilt__` 的时候参数错误
|
||||||
|
- 应该是使用 `arg_value` 判断类型
|
||||||
|
- 但实际上用了 `value`
|
||||||
|
- 把 `is True` 改成了双层判断
|
||||||
|
- `isinstance(value, bool)`
|
||||||
|
- `if value:`
|
||||||
|
|
||||||
## 0.3.12
|
## 0.3.12
|
||||||
|
|
||||||
- `Options`
|
- `Options`
|
||||||
|
@ -9,7 +9,7 @@ from typing import TYPE_CHECKING
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from lib_not_dr import loggers, nuitka, types, command
|
from lib_not_dr import loggers, nuitka, types, command
|
||||||
|
|
||||||
_version_ = "0.3.12"
|
_version_ = "0.3.14"
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
@ -39,7 +39,8 @@ def pyproject_toml(toml_data: dict) -> raw_config_type:
|
|||||||
|
|
||||||
if "main" not in nuitka_config["cli"]:
|
if "main" not in nuitka_config["cli"]:
|
||||||
raise ValueError(
|
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
|
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():
|
for name, value in cli_config.items():
|
||||||
if name in toml_config:
|
if name in toml_config:
|
||||||
warn(
|
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 isinstance(toml_config[name], bool):
|
||||||
if not isinstance(value, bool):
|
if not isinstance(value, bool):
|
||||||
@ -143,17 +145,18 @@ def gen_subprocess_args(
|
|||||||
nuitka_config = merge_cli_config(nuitka_config, get_cli_nuitka_args())
|
nuitka_config = merge_cli_config(nuitka_config, get_cli_nuitka_args())
|
||||||
|
|
||||||
def parse_value(arg_name, arg_value) -> list:
|
def parse_value(arg_name, arg_value) -> list:
|
||||||
if isinstance(value, bool):
|
if isinstance(arg_value, bool):
|
||||||
warn(f"bool value is not supported in list config {arg_name}")
|
warn(f"bool value is not supported in list config {arg_name}")
|
||||||
return []
|
return []
|
||||||
elif isinstance(value, str):
|
elif isinstance(arg_value, str):
|
||||||
return [f"--{arg_name}={arg_value}"]
|
return [f"--{arg_name}={arg_value}"]
|
||||||
else:
|
else:
|
||||||
return [f"--{arg_name}={arg_value[0]}={arg_value[1]}"]
|
return [f"--{arg_name}={arg_value[0]}={arg_value[1]}"]
|
||||||
|
|
||||||
for name, value in nuitka_config.items():
|
for name, value in nuitka_config.items():
|
||||||
if value is True:
|
if isinstance(value, bool):
|
||||||
# --<name>
|
# --<name>
|
||||||
|
if value:
|
||||||
cmd_list.append(f"--{name}")
|
cmd_list.append(f"--{name}")
|
||||||
continue
|
continue
|
||||||
elif isinstance(value, str):
|
elif isinstance(value, str):
|
||||||
@ -181,6 +184,7 @@ def gen_subprocess_args(
|
|||||||
for item in value:
|
for item in value:
|
||||||
cmd_list += parse_value(name, item)
|
cmd_list += parse_value(name, item)
|
||||||
continue
|
continue
|
||||||
|
warn(f"invalid config {name}:{value}")
|
||||||
|
|
||||||
return cmd_list
|
return cmd_list
|
||||||
|
|
||||||
@ -193,8 +197,11 @@ def parse_raw_config_by_script(raw_config: raw_config_type) -> nuitka_config_typ
|
|||||||
:param raw_config:
|
:param raw_config:
|
||||||
:return: parsed config
|
:return: parsed config
|
||||||
"""
|
"""
|
||||||
if (script_name := raw_config.get("script")) is None:
|
raw_cli_config: nuitka_config_type = raw_config.get("cli", {}) # type: ignore
|
||||||
return raw_config["cli"]
|
|
||||||
|
if (script_name := raw_config.get("script")) is None: # type: ignore
|
||||||
|
return raw_cli_config
|
||||||
|
script_name: str
|
||||||
print(f'reading script {script_name}')
|
print(f'reading script {script_name}')
|
||||||
script_path = Path(script_name)
|
script_path = Path(script_name)
|
||||||
|
|
||||||
@ -205,21 +212,22 @@ def parse_raw_config_by_script(raw_config: raw_config_type) -> nuitka_config_typ
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"script {script_path} import failed ignore it\n{e}")
|
print(f"script {script_path} import failed ignore it\n{e}")
|
||||||
sys.path.remove(str(script_path.parent))
|
sys.path.remove(str(script_path.parent))
|
||||||
return raw_config["cli"]
|
return raw_cli_config
|
||||||
|
|
||||||
sys.path.remove(str(script_path.parent))
|
sys.path.remove(str(script_path.parent))
|
||||||
|
|
||||||
if not hasattr(script_module, "main"):
|
if not hasattr(script_module, "main"):
|
||||||
print(f"script {script_path} has no paser function ignore it")
|
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:
|
try:
|
||||||
parsed_config = script_module.main(raw_config)
|
parsed_config = parse_func(raw_config)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"script {script_path} parse failed ignore it")
|
print(f"script {script_path} parse failed ignore it")
|
||||||
print(e)
|
print(e)
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return raw_config["cli"]
|
return raw_cli_config
|
||||||
|
|
||||||
return parsed_config
|
return parsed_config
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user