INNER CODE UNIT · Python
converted_script
libriscv/godot-sandbox · scripts/demo_compat.py:404
def converted_script(project: Path, script: Path, scripts: Sequence[Path]) -> bytes:
known = {path.resolve() for path in scripts}
def convert(match: re.Match[bytes]) -> bytes:
token = match.group()
if token[:1] == b"#" or token.startswith((b'"""', b"\x27\x27\x27")):
return token
path_bytes = token[1:-1]
if not path_bytes.endswith(b".gd") or b"\\" in path_bytes:
return token
path = path_bytes.decode("utf-8")
if path.startswith("res://"):
target = project / path[6:]
elif "://" in path or Path(path).is_absolute():
return token
else:
target = script.parent / path
if target.resolve() not in known: