build(python): simplify rpycdec vendor layout

This commit was merged in pull request #17.
This commit is contained in:
2026-09-06 17:22:16 -04:00
parent 884789d676
commit aab32198d1
56 changed files with 10 additions and 19 deletions

View File

@@ -0,0 +1,28 @@
import re
def encode_say_string(s):
"""
Encodes a string in the format used by Ren'Py say statements.
"""
s = s.replace("\\", "\\\\")
s = s.replace("\n", "\\n")
s = s.replace('"', '\\"')
s = re.sub(r"(?<= ) ", "\\ ", s)
return '"' + s + '"'
def quote_unicode(s):
s = s.replace("\\", "\\\\")
s = s.replace('"', '\\"')
s = s.replace("\a", "\\a")
s = s.replace("\b", "\\b")
s = s.replace("\f", "\\f")
s = s.replace("\n", "\\n")
s = s.replace("\r", "\\r")
s = s.replace("\t", "\\t")
s = s.replace("\v", "\\v")
return s

View File

@@ -0,0 +1,27 @@
import os
import renpy
def shorten_filename(filename):
"""
Shortens a file name. Returns the shortened filename, and a flag that says
if the filename is in the common directory.
"""
commondir = os.path.normpath(renpy.config.commondir) # type: ignore
gamedir = os.path.normpath(renpy.config.gamedir)
if filename.startswith(commondir):
fn = os.path.relpath(filename, commondir)
common = True
elif filename.startswith(gamedir):
fn = os.path.relpath(filename, gamedir)
common = False
else:
fn = os.path.basename(filename)
common = False
return fn, common

View File

@@ -0,0 +1,9 @@
STRING_RE = r"""(?x)
\b(?:_|__|___|_p)
\s*(\((?:[\s\\\n]*[uU]?(?:
\"\"\"(?:\\.|\\\n|\"{1,2}|[^\\"])*?\"\"\"
|'''(?:\\.|\\\n|\'{1,2}|[^\\'])*?'''
|"(?:\\.|\\\n|[^\\"])*"
|'(?:\\.|\\\n|[^\\'])*'
))+\s*\))
"""