/
__main__.py
80 lines (65 loc) · 2.09 KB
/
__main__.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
73
74
# coding=gbk
import sys
import getopt
from mscore import Core
import os
from config import Config
from shutil import copyfile
from globals import Globals
class MoneySea:
def __init__(self):
pass
def usage(self):
print "python __main__.py [-h | -s | -S filepath | -v stockdir [-p] | -u | -t]"
print " -h: show holded stocks in simple format"
print " -s: show selected stocks"
print " -v: show verbose info of this stock"
print " -S: set selected stocks file"
print " -p: only for -v function, indicate using info in selected stocks"
print " -u: update price list"
print " -t: run test"
print " -g: show earing adding list"
print " -a: adjust n and p values [ -a n=val p=val ]"
print ""
def run(self):
self._core = Core()
self.input()
pass
def input(self):
try:
opts, args = getopt.getopt(sys.argv[1:], "hsv:S:pguta", [])
except:
self.usage()
sys.exit(2)
for o, a in opts:
if o == "-p":
Globals.get_instance().setOption(Config.OPTION_SELECTED)
for o, a in opts:
if o == "-h":
self._core.holded()
elif o == "-s":
self._core.selected()
elif o == "-v":
self._core.verbose(a)
elif o == "-S":
try:
os.unlink(Config.SELECTED_PATH)
except:
pass
copyfile(a, Config.SELECTED_PATH)
elif o == "-u":
self._core.updateprice()
elif o == "-t":
self._core.test()
elif o == "-g":
self._core.growinglist()
elif o == "-a":
self._core.adjust(args)
break
pass
if __name__ == "__main__":
if sys.getdefaultencoding() != 'utf-8':
reload(sys)
sys.setdefaultencoding('utf-8')
ms = MoneySea()
ms.run()