initial commit

This commit is contained in:
Bacruru Sakaguchi
2025-09-12 17:10:13 +07:00
commit 9e5e214944
57 changed files with 1538 additions and 0 deletions

31
pythonapp/Decider/misc.py Normal file
View File

@@ -0,0 +1,31 @@
from pathlib import Path
from pythonapp.Decider.Loader import RequirementInfo
def requirements_separator(req_file: Path | str):
try:
with open(req_file, 'r') as file:
lines = [line.strip() for line in file]
req = []
opt = []
req_bool = True
for line in lines:
if line.startswith("#"): req_bool = False
if req_bool: req.append(line)
else: opt.append(line)
except FileNotFoundError:
raise RuntimeError(f"File {req_file} not exists")
return req, opt
def requirements_converter(req: list[str], opt: list[str]) -> list[RequirementInfo]:
res: list[RequirementInfo] = []
for line in req:
if line.startswith("#") or line == '': continue
res.append(RequirementInfo.from_requirement_string(line.split(" ")[0].strip(), 'required', 'requested'))
for line in opt:
if line.startswith("#") or line == '': continue
res.append(RequirementInfo.from_requirement_string(line.split(" ")[0].strip(), 'optional', 'requested'))
return res