diff options
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/decompressor.py | 15 | ||||
| -rw-r--r-- | libs/zipper.py | 14 |
2 files changed, 29 insertions, 0 deletions
diff --git a/libs/decompressor.py b/libs/decompressor.py new file mode 100644 index 0000000..c54dec9 --- /dev/null +++ b/libs/decompressor.py @@ -0,0 +1,15 @@ +from os.path import exists +import zlib + +def decompress_arima(): + if not exists('arima.pkl'): + if not exists('arima.compressed'): + raise FileNotFoundError('arima.compressed not found') + else: + print('Decompressing arima.compressed') + with open('arima.compressed', 'rb') as f: + data = zlib.decompress(f.read()) + with open('arima.pkl', 'wb') as f: + f.write(data) + +decompress_arima()
\ No newline at end of file diff --git a/libs/zipper.py b/libs/zipper.py new file mode 100644 index 0000000..7e5b476 --- /dev/null +++ b/libs/zipper.py @@ -0,0 +1,14 @@ +import zlib +from os.path import exists +from os import remove + + +filename_in = "arima.pkl" +filename_out = "arima.compressed" +if exists(filename_out): + remove(filename_out) +with open(filename_in, mode="rb") as fin, open(filename_out, mode="wb") as fout: + data = fin.read() + print("Compressing Pickle File...") + compressed_data = zlib.compress(data, zlib.Z_BEST_COMPRESSION) + fout.write(compressed_data)
\ No newline at end of file |
