py_stepik/hardcfiles.py

22 lines
408 B
Python

import pickle
import base64
import sys
import zlib
files = {}
for name in sys.argv[1:]:
name = name.replace("\\", "/")
if name.startswith("./"):
name = name[2:]
with open(name, "rb") as f:
data = f.read()
files[name] = data
data = pickle.dumps(files)
compressed_data = zlib.compress(data, 9)
print(base64.b85encode(compressed_data).decode("ascii"))