feat: add native Tomie adapter and strict import compatibility checks
This commit is contained in:
1 parent
c8d83b3fe7
commit
57a4edcbfd
45 files changed
+2985
-71
No files matched your search
@@ -10,6 +10,8 @@ from app.converter.rpy_parser import ScriptData
|
||||
|
||||
def target(path, script: str) -> str:
|
||||
if isinstance(path, dict):
|
||||
if "template" in path or set(path) - {"name", "value"}:
|
||||
raise ValueError("Динамический адрес перехода Naninovel пока не поддерживается")
|
||||
return "nani:" + str(path.get("name") or script) + ("." + str(path["value"]) if path.get("value") else "")
|
||||
if not isinstance(path, str) or "{" in path:
|
||||
raise ValueError("Динамический адрес перехода Naninovel пока не поддерживается")
|
||||
@@ -24,6 +26,13 @@ def compile_package(package) -> tuple[ScriptData, str, dict]:
|
||||
counts[message] += 1
|
||||
locations.setdefault(message, location)
|
||||
|
||||
resource_sources = {}
|
||||
for record in package.texts.values():
|
||||
key = (record.get("collection"), record["key"], record["part"], record.get("occurrence", 0))
|
||||
if key in resource_sources and resource_sources[key] != record["text"]:
|
||||
issue(f"Неоднозначный исходный текст Naninovel: {key[0]}/{key[1]}", record["origin"])
|
||||
resource_sources[key] = record["text"]
|
||||
|
||||
def text(value):
|
||||
value = value.get("template", "") if isinstance(value, dict) else value
|
||||
if not isinstance(value, str):
|
||||
@@ -45,7 +54,10 @@ def compile_package(package) -> tuple[ScriptData, str, dict]:
|
||||
return value
|
||||
|
||||
def expression(value):
|
||||
return nani_expr.expr(static(value, "сценарное выражение"))
|
||||
ast = nani_expr.parse(static(value, "сценарное выражение"))
|
||||
# PGVN uses Python truthiness; Naninovel also treats strings "false",
|
||||
# "0" and "null" as false. Convert conditions inside the Nani evaluator.
|
||||
return {"k": "nani", "ast": ["unary", "!", ["unary", "!", ast]]}
|
||||
|
||||
all_targets, all_names = [], set()
|
||||
for script_name, script in package.scripts.items():
|
||||
|
||||
Reference in new issue
Block a user