-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBUFEX.py
More file actions
85 lines (66 loc) · 2.72 KB
/
BUFEX.py
File metadata and controls
85 lines (66 loc) · 2.72 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
#!/usr/local/bin/python3
# To Do List:
# 1) Make sure that the game file is *actually* the game file when it is opened
# 2) Check for empty records at end of trade, roster & contract files
# Line 339 fail in _subs occurs when there are empty rows in roster.csv
import sys
import BUFEX_subs as sub
import argparse
import globalvars
parser = argparse.ArgumentParser(description='Process CL Options, if any.')
parser.add_argument("-D","--DEBUG", action="store", dest="debug", type=int, default=0,help="Sets Debugging Level")
parser.add_argument("-F","--FILE", action="store", dest="commandfile",help="Command Script File")
parser.add_argument("-M","--MASTER",action="store",dest="masterfile",help="Master Game File")
parser.add_argument("-A","--ACTION",action="store",dest="action",help="Action to Execute")
parser.add_argument("-N","--NAME",action="store",dest="sessionname",help="Trading Session Name")
parser.add_argument("-T","--TRADING",action="store",dest="trading",help="Trading File Name")
parser.add_argument("-S","--SETTLEMENT",action="store",dest="settlefile",help="Settlement File Name")
globalvars.CLoptions = parser.parse_args()
globalvars.debug = globalvars.CLoptions.debug
if globalvars.debug>3:
print(globalvars.CLoptions)
print(globalvars.debug)
main_action = "Z"
game_file = None
while main_action != "E":
if globalvars.CLoptions.commandfile!=None:
# There is a command file present, so process it
print(" HI MOM! ")
elif globalvars.CLoptions.action != None:
# There is a command given, so do it
main_action=globalvars.CLoptions.action
else:
# Interactive only
print ("Do you want to")
print (" [C]reate new game")
print (" [D]eposit Money In Account** ")
print (" [P]rint Account Statements ")
print (" [S]ettle Trades Only")
print (" [T]rade Data Import ")
print (" [E]xit ")
main_action = input("Choose Action: ")
if globalvars.CLoptions.masterfile != None:
# A master game file is specified
game_file = globalvars.CLoptions.masterfile
print ("MAIN_ACTION: %s " % main_action )
if main_action=="C":
sub.create_new_game(game_file)
elif main_action=="P":
game_file=sub.open_game_file(game_file)
sub.print_account_statements(game_file)
elif (main_action=="T" or main_action=="S"):
if game_file == None:
game_file=sub.open_game_file(game_file)
##### Check here to make sure that first line of 'game file' is what it
##### should be to prevent choosing wrong file.
sub.import_trading_data(game_file,main_action=="T")
elif main_action=="D":
print ("DEPOSIT MONEY IN ACCOUNT CODE (NOT IMPLEMENTED)")
elif main_action=="E":
continue
else:
print ("oops")
print(main_action)
if globalvars.CLoptions.action != None:
main_action="E"
print ("NOW EXITING BUFEX ACCOUNTING")