This commit is contained in:
CensoredUsername 2024-03-31 20:59:40 +02:00 committed by ed
parent dba3430b31
commit e264ca85bd
4 changed files with 45 additions and 1 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "scripts/corrupy"]
path = scripts/corrupy
url = git@github.com:CensoredUsername/corrupy.git

1
scripts/corrupy Submodule

@ -0,0 +1 @@
Subproject commit 82ecacb1a81cdd726748a8fc2aa4b72f6d3a33a6

View File

@ -150,12 +150,15 @@ unc="$HOME/dev/copyparty/scripts/uncomment.py"
tr '\n' '\0' |
xargs -0 $pybin $unc 1
echo
echo minimizing files
$pybin ../scripts/squish.py $(find site-packages/r0c -type f)
echo
echo creating tar
args=(--owner=1000 --group=1000)
[ "$OSTYPE" = msys ] &&
args=()
(for d in clients site-packages; do
find $d -type f;
done) |

37
scripts/squish.py Normal file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env python3
import sys
PY2 = sys.version_info < (3,)
from corrupy import minimize
def main():
if len(sys.argv) < 2:
raise ValueError("No command line arguments given. Expected one or more filenames")
for filename in sys.argv[1:]:
print("minimizing {}".format(filename))
if PY2:
with open(filename, "rb") as f:
data = f.read()
else:
with open(filename, "r", encoding="utf-8") as f:
data = f.read()
output = minimize.minimize(
data,
remove_docs=True, obfuscate_globals=False,
obfuscate_builtins=False, obfuscate_imports=False
)
if PY2:
with open(filename, "wb") as f:
f.write(output)
else:
with open(filename, "w", encoding="utf-8") as f:
f.write(output)
if __name__ == '__main__':
main()