Skip to content

Commit 78d1f62

Browse files
committed
Add method to create workdir structure
1 parent 3aeb4a8 commit 78d1f62

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

ACedIt/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def validate_args(args):
1111
sys.exit(0)
1212

1313
if args['source'] and (args['contest'] or args['problem'] or args['force']):
14-
print 'ACedIt run <source_file> doesn\'t support other flags'
14+
print 'ACedIt --run <source_file> doesn\'t support other flags'
1515
sys.exit(0)
1616
elif args['source']:
1717
return

ACedIt/util.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,32 @@ def parse_flags():
8585

8686
return flags
8787

88+
@staticmethod
89+
def create_workdir_structure(site, contest):
90+
"""
91+
Method to create the working directory structure
92+
"""
93+
try:
94+
with open(os.path.join(Utilities.cache_dir, 'constants.json'), 'r') as f:
95+
data = f.read()
96+
data = json.loads(data)
97+
except:
98+
pass
99+
100+
workdir = data.get('workdir', None)
101+
102+
if not os.path.isdir(os.path.join(workdir,site,contest)):
103+
os.makedirs(os.path.join(workdir,site,contest))
104+
88105
@staticmethod
89106
def check_cache(site, contest, problem):
90107
"""
91108
Method to check if the test cases already exist in cache
92109
If not, create the directory structure to store test cases
93110
"""
111+
112+
Utilities.create_workdir_structure(site, contest)
113+
94114
if problem is None:
95115
if not os.path.isdir(os.path.join(Utilities.cache_dir, site, contest)):
96116
os.makedirs(os.path.join(Utilities.cache_dir, site,

0 commit comments

Comments
 (0)