Documents, update, and removes obsolete scripts.

This commit is contained in:
Tom Rothamel
2022-01-09 23:59:13 -05:00
parent d1c154f410
commit 88fa289014
13 changed files with 138 additions and 397 deletions
+100
View File
@@ -0,0 +1,100 @@
Scripts
=======
alter_translations.py
---------------------
This can be used to replace one string translation with another. It's used
when the string changes from `old` to `new`, but the translatoons are
expected to be correct.
autobuild.sh
------------
This is called from distribute.py, to build Ren'Py before distribution
happens.
check_copyright.py
------------------
Checks the copyright notice is present.
checksums.py
------------
Used by add.py. This computes the checksums of a released Ren'Py, and
signs them using GPG.
fix_translations.py
-------------------
Removes BOMs and TODO comments from translations.
generate_pyi.py
---------------
This must be run using a Python with the Ren'Py and pygame_sdl2 modules
built for it. This generates .pyi files in typings/ and renpy, allowing
tools to analyze Ren'Py.
generate_update_keys.py
-----------------------
Generate update keys that can be used by the Ren'Py updater.
mac/
----
Scripts used to sign mac apps.
pyi/
----
Pyi files used by generate_pyi.py.
relative_imports.py
--------------------
This generates the relative import sections of __init__.py files. These fake
the imports, allowing typing tools to find all of Ren'Py.
release_changes.py
------------------
Shows how files have changed in size between releases.
rt/
---
Contains a template game for testing.
rt.py
-----
A tool that helps with creating and running test games.
sign_update.py
---------------
This signs updates used by the Ren'Py updater.
update_compat_import.py
-----------------------
Updates the ``from renpy.compat import`` line at the start of files that
have one.
update_copyright.py
-------------------
Updates the copyright line when the year changes.
update_piglatin.sh
------------------
Updates the piglatin translation.
utflf.py
--------
Fixes line endings and adds UTF-8 BOM to all rpy files in a directory.
-80
View File
@@ -1,80 +0,0 @@
#!/usr/bin/env python3
import sys
import re
import subprocess
# Things to check on an ongoing basis:
#
# * No .iter methods.
# * No print(file=...)
VERBOTEN0 = [
"keys",
"items",
"values",
]
VERBOTEN = [
"six",
"cPickle",
"iteritems",
"itervalues",
"iterkeys",
"has_key",
"unichr",
"chr",
"unicode",
]
def process(fn):
subprocess.call(["futurize", "-x", "lib2to3.fixes.fix_dict", fn])
print("--------------------------")
with open(fn) as f:
for i, l in enumerate(f):
found = False
i += 1
for j in VERBOTEN0:
if re.search(r'\b' + j + r'\b', l):
found = True
if found:
l = l.rstrip()
print(f"{i:04d} {l}")
print("--------------------------")
with open(fn) as f:
for i, l in enumerate(f):
found = False
i += 1
for j in VERBOTEN:
if re.search(r'\b' + j + r'\b', l):
found = True
if found:
l = l.rstrip()
print(f"{i:04d} {l}")
def main():
for fn in sys.argv[1:]:
process(fn)
if __name__ == "__main__":
main()
Regular → Executable
+21 -11
View File
@@ -1,10 +1,13 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import print_function
import os.path
import os
import re
import codecs
import datetime
import pathlib
ENDINGS = [
".rpy",
@@ -28,6 +31,9 @@ module/pysdlsound/__init__.py
module/build/
module/include/
module/gen/
module/gen3/
module/gen-static/
module/gen3-static/
launcher/game/EasyDialogsResources.py
launcher/game/EasyDialogsWin.py
launcher/game/pefile.py
@@ -53,23 +59,22 @@ def process_file(fn):
has_license = False
first = True
with open(fn, "rb") as f:
with open(fn, "r") as f:
for l in f:
if fn.endswith(".rpy") or fn.endswith(".rpym"):
if first:
if codecs.BOM_UTF8 not in l:
if "\ufeff" not in l:
print("Missing BOM", fn)
first = False
else:
if codecs.BOM_UTF8 in l:
if "\ufeff" in l:
print("Extra BOM", fn)
first = False
m = re.search(
r"Copyright (\d{4})-2015 Tom Rothamel",
r"Copyright (\d{4})-%d Tom Rothamel" % datetime.datetime.now().year,
l)
if m:
@@ -91,8 +96,13 @@ def process(root):
fn = os.path.join(dirname, fn)
process_file(fn)
process_file("renpy.py")
process("renpy")
process("module")
process("launcher/game")
if __name__ == "__main__":
os.chdir(pathlib.Path(__file__).absolute().parent.parent)
print(os.getcwd())
process_file("renpy.py")
process("renpy")
process("module")
process("launcher/game")
-44
View File
@@ -1,44 +0,0 @@
#!/usr/bin/env python3
from __future__ import print_function
import sys
def process(fn):
with open(fn) as f:
lines = f.readlines()
for i in lines:
if "__future__" in i:
print("Already in", fn)
return
line = 0
for line, l in enumerate(lines):
if "#" in l:
continue
if not l.strip():
continue
break
print(fn, line)
lines.insert(line, "from __future__ import print_function\n")
lines.insert(line + 1, "\n")
with open(fn, "w") as f:
f.write(''.join(lines))
def main():
for i in sys.argv[1:]:
process(i)
if __name__ == "__main__":
main()
Regular → Executable
View File
Regular → Executable
+7 -5
View File
@@ -1,4 +1,6 @@
import pathlib
#!/usr/bin/env python3
import pathlib
import collections
import re
@@ -17,13 +19,13 @@ def find_modules():
mod = str(i.with_suffix("")).replace("/", ".")
if mod.endswith(".__init__"):
mod = mod[:-9]
modules.append(mod)
# Generated modules.
# Generated modules.
for i in (ROOT / "module" / "gen3").glob("*.c"):
mod = str(i.stem)
modules.append(mod)
modules.sort()
@@ -78,4 +80,4 @@ def main():
if __name__ == "__main__":
main()
main()
-119
View File
@@ -1,119 +0,0 @@
# Scans a file for python style assignments, and turns such lines into
# style statements.
#
# The result of this probably won't be legal Ren'Py, but it should be
# a reasonable starting point for conversions.
from __future__ import print_function
import argparse
import sys
import os
import re
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import renpy
renpy.import_all()
renpy.config.basedir = '/'
renpy.config.renpy_base = '/'
def main():
ap = argparse.ArgumentParser()
ap.add_argument("script")
args = ap.parse_args()
current_name = None
current_parent = None
current_entries = None
def emit():
if not current_name:
return
print()
if current_parent and current_entries:
print("style {} is {}:".format(current_name, current_parent))
elif current_parent:
print("style {} is {}".format(current_name, current_parent))
elif current_entries:
print("style {}:".format(current_name))
else:
print("style {}".format(current_name))
for name, expr in current_entries:
if expr:
print(" {} {}".format(name, expr.strip()))
else:
print(" {}".format(name))
for _fn, _lineno, l in renpy.parser.list_logical_lines(args.script):
m = re.search(r'style\.(\w+)\s*=\s*Style\(\s*(["\'](\w+)["\']|style\.(\w+))', l)
new_name = None
new_parent = None
new_entries = [ ]
if m:
name = m.group(1)
parent = m.group(3) or m.group(4)
new_name = name
new_parent = parent
m = re.search(r'style\.create\(["\'](\w+)["\'],\s*["\'](\w+)["\']', l)
if m:
new_name = m.group(1)
new_parent = m.group(2)
m = re.search(r'style\.(\w+)\.(\w+)\s*=\s*(.*)', l, re.S)
if m:
new_name = m.group(1)
new_entries.append((m.group(2), m.group(3)))
m = re.search(r'style\.(\w+)\.clear\(\)', l)
if m:
new_name = m.group(1)
new_entries.append(("clear", None))
m = re.search(r'style\.(\w+)\.take\((.*)\)', l)
if m:
new_name = m.group(1)
new_entries.append(("take", m.group(2)))
m = re.search(r'style\.(\w+)\.set_parent\(style\.(.*)\)', l)
if m:
new_name = m.group(1)
new_entries.append(("is", m.group(2)))
m = re.search(r'style\.(\w+)\.set_parent\([\'"](.*)[\'"]\)', l)
if m:
new_name = m.group(1)
new_entries.append(("is", m.group(2)))
if new_name is None:
continue
if new_name != current_name:
emit()
current_name = new_name
current_parent = new_parent
current_entries = new_entries
else:
if new_parent:
current_parent = new_parent
current_entries.extend(new_entries)
emit()
if __name__ == "__main__":
main()
Regular → Executable
+5 -3
View File
@@ -1,4 +1,6 @@
import pathlib
#!/usr/bin/env python3
import pathlib
import collections
import re
@@ -12,10 +14,10 @@ def main():
# .py modules.
for p in (ROOT / "renpy").glob("**/*.py"):
text = p.read_text()
text = re.sub(r'^from renpy.compat import(.*)*$', IMPORT_LINE, text, flags=re.MULTILINE)
p.write_text(text)
if __name__ == "__main__":
main()
main()
Regular → Executable
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import print_function
+4 -2
View File
@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# Fixes line endings and adds UTF-8 BOM to all rpy files in a
# directory.
@@ -7,7 +9,7 @@ import sys
def process(fn):
with open(fn, "rb") as f:
with open(fn, "r") as f:
data = f.read()
data = data.decode("utf-8")
@@ -16,7 +18,7 @@ def process(fn):
data = u"\ufeff" + data
data = data.encode("utf-8")
with open(fn, "wb") as f:
with open(fn, "w") as f:
f.write(data)
-46
View File
@@ -1,46 +0,0 @@
#!/usr/bin/env python
# Given two zip files, shows how files have changed in size between
# them.
from __future__ import print_function
import argparse
import zipfile
import collections
def size_zip(fn):
zf = zipfile.ZipFile(fn)
rv = { }
for zi in zf.infolist():
_basedir, _, filename = zi.filename.partition("/")
rv[filename] = zi.compress_size
return rv
def main():
ap = argparse.ArgumentParser()
ap.add_argument("zip")
args = ap.parse_args()
files = size_zip(args.zip)
dirsizes = collections.defaultdict(int)
for k, v in files.items():
while k:
k, _, _ = k.rpartition('/')
dirsizes[k] += v
sizes = [ (v, k) for (k, v) in dirsizes.items() ]
sizes.sort()
for v, k in sizes:
print("{: 9d} {}".format(v, k))
if __name__ == "__main__":
main()
-38
View File
@@ -1,38 +0,0 @@
#!/usr/bin/env python
# Given two zip files, shows how files have changed in size between
# them.
from __future__ import print_function
import argparse
import zipfile
import collections
def size_zip(fn):
zf = zipfile.ZipFile(fn)
rv = { }
for zi in zf.infolist():
_basedir, _, filename = zi.filename.partition("/")
rv[filename] = zi.compress_size
return rv
def main():
ap = argparse.ArgumentParser()
ap.add_argument("zip")
args = ap.parse_args()
files = size_zip(args.zip)
dirsizes = collections.defaultdict(int)
for k, v in files.items():
print("{: 9d} {}".format(v, k))
if __name__ == "__main__":
main()
-48
View File
@@ -1,48 +0,0 @@
#!/usr/bin/env python
# Given two zip files, shows how files have changed in size between
# them.
from __future__ import print_function
import argparse
import zipfile
def size_zip(fn):
zf = zipfile.ZipFile(fn)
rv = { }
for zi in zf.infolist():
_basedir, _, filename = zi.filename.partition("/")
rv[filename] = zi.compress_size
return rv
def main():
ap = argparse.ArgumentParser()
ap.add_argument("old")
ap.add_argument("new")
args = ap.parse_args()
old = size_zip(args.old)
new = size_zip(args.new)
all = list(set(old) | set(new)) # @ReservedAssignment
all.sort()
for fn in all:
old_size = old.get(fn, 0)
new_size = new.get(fn, 0)
if old_size == new_size:
continue
print("{: 6d} {}".format((new_size - old_size), fn))
if __name__ == "__main__":
main()