Added libs

This commit is contained in:
Lucas
2026-01-25 13:55:46 +10:00
parent 575c682afc
commit f70af3c4ea
229 changed files with 26983 additions and 0 deletions

51
app/common/args.py Normal file
View File

@@ -0,0 +1,51 @@
import sys
from typing import Dict, List, Any
def read_kargs(argv: List[str] = None) -> Dict[str, Any]:
"""
Parse command-line arguments in the format key=value.
Example:
python start.py updateApp=True port=8080
Returns:
dict: {
"updateApp": True,
"port": "8080"
}
"""
if argv is None:
argv = sys.argv
kargs: Dict[str, Any] = {}
for param in argv:
if "=" in param:
key, value = param.split("=", 1)
# Normalize booleans
if value.lower() == "true":
value = True
elif value.lower() == "false":
value = False
kargs[key] = value
return kargs
def kargs_to_array(kargs: Dict[str, Any] = None) -> List[str]:
"""
Convert a dictionary of arguments back to an array of key=value.
Example:
{"updateApp": True, "port": 8080}
Returns:
["updateApp=True", "port=8080"]
"""
if not kargs:
kargs = read_kargs()
array: List[str] = []
for key, value in kargs.items():
array.append(f"{key}={value}")
return array