forked from thouis/pycpx
-
Notifications
You must be signed in to change notification settings - Fork 1
/
handleErrCode.py
47 lines (39 loc) · 972 Bytes
/
handleErrCode.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
import fileinput
value = None
sym = None
enum = None
meaning = None
StatusCodes = {}
t = 0
for line in fileinput.input():
if t == 0:
value = int(line.rstrip())
pass
elif t == 1:
sym = str(line.rstrip())
pass
elif t == 2:
enum = str(line.rstrip())
pass
elif t == 3:
meaning = str(line.rstrip())
StatusCodes[value] = {'sym': sym, 'enum': enum, 'meaning':meaning}
pass
t = (t + 1)%4
pass
print len(StatusCodes)
codeValues = sorted(StatusCodes.keys())
for v in codeValues:
print "#define %s %d" % (StatusCodes[v]['sym'], v)
pass
print "switch(status) {"
for v in codeValues:
sym = StatusCodes[v]['sym']
enum = StatusCodes[v]['enum']
meaning = StatusCodes[v]['meaning']
print "case %s:" % enum
print " return Status(\"%s\", %s);" % (meaning, sym)
pass
print "default:"
print " return Status(\"Unknown status code from Cplex\");"
print "}"