-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
62 lines (54 loc) · 1.95 KB
/
utils.py
File metadata and controls
62 lines (54 loc) · 1.95 KB
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
import os
import sys
from parseCSV import clean_dir
from segmentPNG import cleanse_dir
from generateCoords import cleanMetadata, cleanDir
def init():
# Clean .gitkeep files before proceeding
print("Cleaning .gitkeep files if they exist")
if os.path.exists('./temp/img/.gitkeep'):
os.remove('./temp/img/.gitkeep')
if os.path.exists('./temp/pdf/.gitkeep'):
os.remove('./temp/pdf/.gitkeep')
if os.path.exists('./sliced/.gitkeep'):
os.remove('./sliced/.gitkeep')
if os.path.exists('./segmentedoutputs/.gitkeep'):
os.remove('./segmentedoutputs/.gitkeep')
if os.path.exists('./metadata/.gitkeep'):
os.remove('./metadata/.gitkeep')
if os.path.exists('./blurred/.gitkeep'):
os.remove('./blurred/.gitkeep')
if os.path.exists('./output/.gitkeep'):
os.remove('./output/.gitkeep')
def deploy():
# Add .gitkeep files before deploying
print("Adding .gitkeep files if they don't exist")
if not os.path.exists('./temp/img/.gitkeep'):
open('./temp/img/.gitkeep', 'w')
if not os.path.exists('./temp/pdf/.gitkeep'):
open('./temp/pdf/.gitkeep', 'w')
if not os.path.exists('./sliced/.gitkeep'):
open('./sliced/.gitkeep', 'w')
if not os.path.exists('./segmentedoutputs/.gitkeep'):
open('./segmentedoutputs/.gitkeep', 'w')
if not os.path.exists('./metadata/.gitkeep'):
open('./metadata/.gitkeep', 'w')
if not os.path.exists('./blurred/.gitkeep'):
open('./blurred/.gitkeep', 'w')
if not os.path.exists('./output/.gitkeep'):
open('./output/.gitkeep', 'w')
def clean(shouldDel):
# Clean out all project directories
clean_dir(shouldDel)
cleanse_dir()
cleanDir()
cleanMetadata()
if __name__ == "__main__":
if 'deploy' in str(sys.argv):
deploy()
elif 'init' in str(sys.argv):
init()
elif 'clean' in str(sys.argv):
clean(False)
else:
raise Exception("Invalid argument")