-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzip.py
64 lines (50 loc) · 1.44 KB
/
zip.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
To zip everything
"""
from zipfile import ZipFile
import os
from src import Args
from src.Args import Parser, ArgType
def get_all_file_paths(directory):
# initializing empty file paths list
file_paths = []
# crawling through directory and subdirectories
for root, directories, files in os.walk(directory):
for filename in files:
# join the two strings in order to form the full filepath.
filepath = os.path.join(root, filename)
file_paths.append(filepath)
# returning all file paths
return file_paths
def main(args):
"""
:param args:
:return:
"""
roots = []
if args.all:
if not args.no_midi:
roots.append('generated_midis')
if not args.no_hp:
roots.append('search_hp')
if not args.no_model:
roots.append('saved_models')
else:
if args.midi:
roots.append('generated_midis')
if args.hp:
roots.append('hp_search')
if args.model:
roots.append('saved_models')
to_zip = []
for root in roots:
to_zip.extend(get_all_file_paths(root))
with ZipFile('my_zip.zip', 'w') as zip:
for file in to_zip:
zip.write(file)
print('Done zipping in my_zip.zip')
if __name__ == '__main__':
parser = Parser(argtype=ArgType.Zip)
args = parser.parse_args()
args = Args.preprocess.zip(args)
main(args)