build(python): simplify rpycdec vendor layout
This commit was merged in pull request #17.
This commit is contained in:
28
third_party/python/rpycdec/src/renpy/translation/__init__.py
vendored
Normal file
28
third_party/python/rpycdec/src/renpy/translation/__init__.py
vendored
Normal 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
|
||||
27
third_party/python/rpycdec/src/renpy/translation/generation.py
vendored
Normal file
27
third_party/python/rpycdec/src/renpy/translation/generation.py
vendored
Normal 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
|
||||
9
third_party/python/rpycdec/src/renpy/translation/scanstrings.py
vendored
Normal file
9
third_party/python/rpycdec/src/renpy/translation/scanstrings.py
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
STRING_RE = r"""(?x)
|
||||
\b(?:_|__|___|_p)
|
||||
\s*(\((?:[\s\\\n]*[uU]?(?:
|
||||
\"\"\"(?:\\.|\\\n|\"{1,2}|[^\\"])*?\"\"\"
|
||||
|'''(?:\\.|\\\n|\'{1,2}|[^\\'])*?'''
|
||||
|"(?:\\.|\\\n|[^\\"])*"
|
||||
|'(?:\\.|\\\n|[^\\'])*'
|
||||
))+\s*\))
|
||||
"""
|
||||
Reference in New Issue
Block a user