forked from jma127/pcu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.py
executable file
·72 lines (56 loc) · 1.64 KB
/
globals.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
65
66
67
68
69
70
71
72
import os
import compile
import log
import make
import run
import testcases
import testgen
# Global Variables
working = os.path.abspath(os.getcwd()) # Current working directory
path = os.path.dirname(os.path.abspath(__file__)) # Path directory
tmpdir = os.path.join(path, 'tmp') # Current temporary directory
logfile = os.path.join(tmpdir, 'log.txt')
sandboxdir = os.path.join(tmpdir, 'sandbox') # Sandbox directory
templatedir = os.path.join(path, 'templates') # Template directory
probdir = None # Problem directory
probsettingsfile = None # File of problem settings dictionary
probsettings = None # Problem settings dictionary
# Command Functions
commands = {
'make': make.make,
'comp': compile.compile,
'setin': testcases.setin,
'setans': testcases.setans,
'testgen': testgen.testgen,
'getin': testcases.getin,
'getans': testcases.getans,
'getout': testcases.getout,
'getstdout': testcases.getstdout,
'getstderr': testcases.getstderr,
'delcases': testcases.delcases,
'run': run.run,
'logstart': log.logstart,
'logmsg': log.logmsg,
'logretr': log.logretr
}
# Reusable Options
reusable = ['langext', 'mode']
# Problem Settings Retrieval
def getsetting (setting):
if setting in probsettings:
return probsettings[setting]
return None
def getprob ():
return getsetting('problem')
def getext ():
return getsetting('langext')
def getsrc ():
return getprob() + '.' + getext()
def getmode ():
return getsetting('mode')
def getnumcases ():
return getsetting('numcases')
def gettestid ():
return getsetting('testid')
def gettestfile ():
return getsetting('filename')