-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompress.py
More file actions
31 lines (24 loc) · 767 Bytes
/
compress.py
File metadata and controls
31 lines (24 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pathlib
import sys
from compression import compressors
def error_message() -> None:
print(
"The command interface is \n"
"./compress <input-filepath> <output-filepath>\n"
"<input-filepath> has to exist"
)
def compress() -> None:
if len(sys.argv) != 3:
return error_message()
input_fp, output_fp = sys.argv[1:]
input_filepath = pathlib.Path(input_fp)
if not input_filepath.exists():
return error_message()
output_filepath = pathlib.Path(output_fp)
Compressor = compressors.COMPRESSORS['bwt']
compressor = Compressor(
input_filepath=input_filepath, output_filepath=output_filepath
) # type: ignore
compressor.compress()
if __name__ == '__main__':
compress()