git24 - changed config file format to match new way of passing around settings inside the code - will use this to facilitate various code cleanups and a generalised method of dealing with settings

got deep links for windows DL for everything
tv option of combined postflop is now exported to profile
This commit is contained in:
steffen123
2008-08-11 00:44:46 +01:00
parent 488af76f8e
commit 9b737612d0
7 changed files with 56 additions and 63 deletions
+25 -34
View File
@@ -241,43 +241,33 @@ class fpdb:
self.profile=filename
self.bulk_import_default_path="/work/poker-histories/wine-ps/" #/todo: move this to .conf
found_backend, found_host, found_database, found_user, found_password=False, False, False, False, False
self.settings={'db-host':"localhost", 'db-backend':2, 'db-databaseName':"fpdb", 'db-user':"fpdb"}
if (os.sep=="/"):
self.settings['os']="linuxmac"
else:
self.settings['os']="windows"
for i in range(len(lines)):
if lines[i].startswith("backend="):
backend=int(lines[i][8:-1])
found_backend=True
elif lines[i].startswith("host="):
host=lines[i][5:-1]
#self.host=host
found_host=True
elif lines[i].startswith("database="):
database=lines[i][9:-1]
#self.database=database
found_database=True
elif lines[i].startswith("user="):
user=lines[i][5:-1]
found_user=True
elif lines[i].startswith("password="):
password=lines[i][9:-1]
found_password=True
if not found_backend:
raise fpdb_simple.FpdbError("failed to read backend from settings file:"+filename)
elif not found_host:
raise fpdb_simple.FpdbError("failed to read host from settings file:"+filename)
elif not found_database:
raise fpdb_simple.FpdbError("failed to read database from settings file:"+filename)
elif not found_user:
raise fpdb_simple.FpdbError("failed to read user from settings file:"+filename)
elif not found_password:
raise fpdb_simple.FpdbError("failed to read password from settings file:"+filename)
if lines[i].startswith("db-backend="):
self.settings['db-backend']=int(lines[i][11:-1])
elif lines[i].startswith("db-host="):
self.settings['db-host']=lines[i][8:-1]
elif lines[i].startswith("db-databaseName="):
self.settings['db-database']=lines[i][16:-1]
elif lines[i].startswith("db-user="):
self.settings['db-user']=lines[i][8:-1]
elif lines[i].startswith("db-password="):
self.settings['db-password']=lines[i][12:-1]
elif lines[i].startswith("tv-combinedPostflop="):
if lines[i].find("True")!=-1:
self.settings['tv-combinedPostflop']=True
else:
self.settings['tv-combinedPostflop']=False
if self.db!=None:
self.db.disconnect()
self.db = fpdb_db.fpdb_db()
self.db.connect(backend, host, database, user, password)
self.db.connect(self.settings['db-backend'], self.settings['db-host'], self.settings['db-databaseName'], self.settings['db-user'], self.settings['db-password'])
#end def load_profile
def not_implemented(self):
@@ -320,15 +310,16 @@ class fpdb:
"""Displays a tab with the main fpdb help screen"""
#print "start of tab_main_help"
mh_tab=gtk.Label("""Welcome to Fpdb!
For howto information please see docs/readme-user.txt
This program is licensed under the AGPL3, see docs/agpl-3.0.txt""")
For howto information please see docs"""+os.sep+"""readme-user.txt
The abbrevations in the table viewer are explained in docs"""+os.sep+"""abbrevations.txt
This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
self.add_and_display_tab(mh_tab, "main help")
#end def tab_main_help
def tab_table_viewer(self, widget, data):
"""opens a table viewer tab"""
#print "start of tab_table_viewer"
new_tv_thread=table_viewer.table_viewer(self.db)
new_tv_thread=table_viewer.table_viewer(self.db, self.settings)
self.threads.append(new_tv_thread)
tv_tab=new_tv_thread.get_vbox()
self.add_and_display_tab(tv_tab, "table viewer")
+5 -5
View File
@@ -57,12 +57,11 @@ class table_viewer (threading.Thread):
"""prepares the data for display by refresh_clicked, returns a 2D array"""
#print "start of prepare_data"
arr=[]
combinedPostflop=True #todo: export as option
#first prepare the header row
if (self.category=="holdem" or self.category=="omahahi" or self.category=="omahahilo"):
tmp=("Name", "Hands", "VPIP", "PFR", "PF3B4B", "AF", "FF", "AT", "FT", "AR", "FR", "SD/F", "W$wsF", "W$@SD")
if (combinedPostflop):
tmp=("Name", "Hands", "VPIP", "PFR", "PF3B4B", "F-R Aggr", "F-R Fold", "SD/F", "W$wsF", "W$@SD")
if self.settings['tv-combinedPostflop']:
tmp=("Name", "Hands", "VPIP", "PFR", "PF3B4B", "Postf A", "Postf F", "SD/F", "W$wsF", "W$@SD")
else:
raise fpdb_simple.FpdbError("reimplement stud")
tmp=("Name", "Hands", "VPI3", "A3", "3B4B_3" "A4", "F4", "A5", "F5", "A6", "F6", "A7", "F7", "SD/4")
@@ -108,7 +107,7 @@ class table_viewer (threading.Thread):
tmp.append(self.hudDivide(row[5],row[4])) #VPIP
tmp.append(self.hudDivide(row[6],row[4])) #PFR
tmp.append(self.hudDivide(row[8],row[7])+" ("+str(row[7])+")") #PF3B4B
if (combinedPostflop):
if self.settings['tv-combinedPostflop']:
aggCount=row[13]+row[14]+row[15]
handCount=row[9]+row[10]+row[11]
foldCount=row[17]+row[19]+row[21]
@@ -222,12 +221,13 @@ class table_viewer (threading.Thread):
return self.main_vbox
#end def get_vbox
def __init__(self, db, debug=True):
def __init__(self, db, settings, debug=True):
"""Constructor for table_viewer"""
self.debug=debug
#print "start of table_viewer constructor"
self.db=db
self.cursor=db.cursor
self.settings=settings
self.main_vbox = gtk.VBox(False, 0)
self.main_vbox.show()