-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstate_helper.py
More file actions
105 lines (77 loc) · 3.26 KB
/
state_helper.py
File metadata and controls
105 lines (77 loc) · 3.26 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Copyright (c) 2023 VISTEC - Vidyasirimedhi Institute of Science and Technology
# Distribute under MIT License
# Authors:
# - Sucha Supittayapornpong <sucha.s[-at-]vistec.ac.th>
# - Kanatip Chitavisutthivong <kanatip.c_s18[-at-]vistec.ac.th>
import os
HCONST = { 'rootdir' : None,
'precompute directory': 'Precomputation',
'commodity data directory': 'commodity',
'flow data directory': 'flow',
'auxiliary data directory': 'auxiliary',
'stage data directory': 'stage',
'commpath': None,
'flowpath': None,
'auxpath': None,
'stagepath': None,
'output data directory': 'Output',
'outputpath': None,
'split groups directory': 'SplitGroups',
'splitgroupspath': None,
}
def makePrecomputationDirectory():
if HCONST['rootdir'] is None:
print('rootdir has not been set.')
assert False
rootdir = HCONST['rootdir']
if not os.path.exists(rootdir):
os.mkdir(rootdir)
if not os.path.exists(rootdir + '/' + HCONST['precompute directory']):
os.mkdir(rootdir + '/' + HCONST['precompute directory'])
topopath = HCONST['topopath']
if not os.path.exists(topopath):
os.mkdir(topopath)
commpath = HCONST['commpath']
if not os.path.exists(commpath):
os.mkdir(commpath)
flowpath = HCONST['flowpath']
if not os.path.exists(flowpath):
os.mkdir(flowpath)
auxpath = HCONST['auxpath']
if not os.path.exists(auxpath):
os.mkdir(auxpath)
stagepath = HCONST['stagepath']
if not os.path.exists(stagepath):
os.mkdir(stagepath)
def makeOutputDirectory():
if HCONST['rootdir'] is None:
print('rootdir has not been set. No data is save.')
assert False
rootdir = HCONST['rootdir']
if not os.path.exists(rootdir):
os.mkdir(rootdir)
if not os.path.exists(HCONST['rootdir'] + '/' + HCONST['output data directory']):
os.mkdir(HCONST['rootdir'] + '/' + HCONST['output data directory'])
outputpath = HCONST['outputpath']
if not os.path.exists(outputpath):
os.mkdir(outputpath)
def initHCONST(rootdir, toponame):
HCONST['rootdir'] = rootdir
topopath = HCONST['rootdir'] + '/' + HCONST['precompute directory'] + '/' + toponame
HCONST['topopath'] = topopath
commpath = HCONST['topopath'] + '/' + HCONST['commodity data directory']
HCONST['commpath'] = commpath
flowpath = HCONST['topopath'] + '/' + HCONST['flow data directory']
HCONST['flowpath'] = flowpath
auxpath = HCONST['topopath'] + '/' + HCONST['auxiliary data directory']
HCONST['auxpath'] = auxpath
outputpath = HCONST['rootdir'] + '/' + HCONST['output data directory'] + '/' + toponame
HCONST['outputpath'] = outputpath
stagepath = HCONST['topopath'] + '/' + HCONST['stage data directory']
HCONST['stagepath'] = stagepath
splitgroupspath = HCONST['rootdir'] + '/' + HCONST['output data directory'] + '/' + toponame + '/' + HCONST['split groups directory']
HCONST['splitgroupspath'] = splitgroupspath
def makeSplitGroupsDirectory():
splitgroupspath = HCONST['splitgroupspath']
if not os.path.exists(splitgroupspath):
os.mkdir(splitgroupspath)