-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpylotto.py
70 lines (61 loc) · 2.06 KB
/
pylotto.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#
# Copyright 2013 Elad Cohen <[email protected]>
##########################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##########################################
import fileDl,loadRes
from Stats import *
from os import chdir
from sys import argv,exit
__version__ = 'v1.02'
__Author__ = 'Elad Cohen'
## CL usage message
def usage():
print 'pylotto' , __version__ ,': invalid argument.\n',
print 'Usage: pylotto.py 777\n pylotto.py Lotto'
return 0
## CL arguments
def parseArgs():
if len(argv)<2:
usage()
elif argv[1] == '777' or argv[1] == 'Lotto':
return argv[1]
else:
usage()
## Main
def main(draw_type):
if not draw_type: # exit if arguments are wrong
return 0
update = raw_input(r'Do you want to update the draw results file? (Y\n): ')
if update == 'Y':
fileDl.fChk(draw_type) #check for updated results file
elif update != 'n':
print "Invalid choice, Exiting..."
return 0
else:
chdir(draw_type) # change directory to the selected draw
draw = loadRes.readRes(draw_type) #load results from csv file
print 'Latest draw loaded:' , draw.results[0][0]
print 'Latest draw results:'
for i in draw.results[0][1:]:
print i, '-',
print '\nWriting draw statistics... (draw_stats.csv)'
print 'Writing ball statistics... (ball_stats.csv)'
writeStats(draw_type, draw.results) # write statistics to a csv file
print 'Done.'
if __name__== '__main__':
args = parseArgs()
exit(main(args))