Merge branch 'master' of git://git.assembla.com/fpdb
This commit is contained in:
commit
238631aec7
|
@ -1694,11 +1694,11 @@ class Database:
|
||||||
|
|
||||||
def storeHand(self, p, printdata = False):
|
def storeHand(self, p, printdata = False):
|
||||||
if printdata:
|
if printdata:
|
||||||
print "######## Hands ##########"
|
print _("######## Hands ##########")
|
||||||
import pprint
|
import pprint
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
pp.pprint(p)
|
pp.pprint(p)
|
||||||
print "###### End Hands ########"
|
print _("###### End Hands ########")
|
||||||
#stores into table hands:
|
#stores into table hands:
|
||||||
q = self.sql.query['store_hand']
|
q = self.sql.query['store_hand']
|
||||||
|
|
||||||
|
|
|
@ -118,11 +118,11 @@ class GuiReplayer:
|
||||||
self.table[i]={"name":self.MyHand.players[i][1],"stack":Decimal(self.MyHand.players[i][2]),"x":x,"y":y,"chips":0,"status":"live"} #save coordinates of each player
|
self.table[i]={"name":self.MyHand.players[i][1],"stack":Decimal(self.MyHand.players[i][2]),"x":x,"y":y,"chips":0,"status":"live"} #save coordinates of each player
|
||||||
try:
|
try:
|
||||||
self.table[i]['holecards']=self.MyHand.holecards["PREFLOP"][self.MyHand.players[i][1]][1]+' '+self.MyHand.holecards["PREFLOP"][self.MyHand.players[i][1]][2]
|
self.table[i]['holecards']=self.MyHand.holecards["PREFLOP"][self.MyHand.players[i][1]][1]+' '+self.MyHand.holecards["PREFLOP"][self.MyHand.players[i][1]][2]
|
||||||
print "holecards",self.table[i]['holecards']
|
print "holecards: ",self.table[i]['holecards']
|
||||||
except:
|
except:
|
||||||
self.table[i]['holecards']=''
|
self.table[i]['holecards']=''
|
||||||
except IndexError: #if seat is empty
|
except IndexError: #if seat is empty
|
||||||
print "seat",i+1,"out of",self.maxseats,"empty"
|
print "seat ",i+1," out of ",self.maxseats," empty"
|
||||||
|
|
||||||
self.actions=[] #create list with all actions
|
self.actions=[] #create list with all actions
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ class GuiReplayer:
|
||||||
rect = gtk.gdk.Rectangle(270,270,100,50)
|
rect = gtk.gdk.Rectangle(270,270,100,50)
|
||||||
self.area.window.invalidate_rect(rect, True) #refresh pot area
|
self.area.window.invalidate_rect(rect, True) #refresh pot area
|
||||||
self.area.window.process_updates(True)
|
self.area.window.process_updates(True)
|
||||||
print "draw action",self.action_number,self.actions[self.action_number][1],self.actions[self.action_number][2],self.actions[self.action_number][3]
|
print "draw action: ",self.action_number,self.actions[self.action_number][1],self.actions[self.action_number][2],self.actions[self.action_number][3]
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -155,15 +155,10 @@ class GuiSessionViewer (threading.Thread):
|
||||||
# make sure Hand column is not displayed
|
# make sure Hand column is not displayed
|
||||||
#[x for x in self.columns if x[0] == 'hand'][0][1] = False
|
#[x for x in self.columns if x[0] == 'hand'][0][1] = False
|
||||||
if DEBUG == False:
|
if DEBUG == False:
|
||||||
warning_string = """
|
warning_string = _("Session Viewer is proof of concept code only, and contains many bugs.\n")
|
||||||
Session Viewer is proof of concept code only, and contains many bugs.
|
warning_string += _("Feel free to use the viewer, but there is no guarantee that the data is accurate.\n")
|
||||||
|
warning_string += _("If you are interested in developing the code further please contact us via the usual channels.\n")
|
||||||
Feel free to use the viewer, but there is no guarantee that the data is accurate.
|
warning_string += _("Thankyou")
|
||||||
|
|
||||||
If you are interested in developing the code further please contact us via the usual channels.
|
|
||||||
|
|
||||||
Thankyou
|
|
||||||
"""
|
|
||||||
self.warning_box(warning_string)
|
self.warning_box(warning_string)
|
||||||
|
|
||||||
def warning_box(self, str, diatitle=_("FPDB WARNING")):
|
def warning_box(self, str, diatitle=_("FPDB WARNING")):
|
||||||
|
|
|
@ -54,15 +54,10 @@ class GuiStove():
|
||||||
self.mainHBox.show_all()
|
self.mainHBox.show_all()
|
||||||
|
|
||||||
if DEBUG == False:
|
if DEBUG == False:
|
||||||
warning_string = _("""
|
warning_string = _("Stove is a GUI mockup of a EV calculation page, and completely non functional.\n")
|
||||||
Stove is a GUI mockup of a EV calculation page, and completely non functional.
|
warning_string = _("Unless you are interested in developing this feature, please ignore this page.\n")
|
||||||
|
warning_string = _("If you are interested in developing the code further see GuiStove.py and Stove.py\n")
|
||||||
Unless you are interested in developing this feature, please ignore this page.
|
warning_string = _("Thank you\n")
|
||||||
|
|
||||||
If you are interested in developing the code further see GuiStove.py and Stove.py
|
|
||||||
|
|
||||||
Thankyou
|
|
||||||
""")
|
|
||||||
self.warning_box(warning_string)
|
self.warning_box(warning_string)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,7 @@ def idle_resize(hud):
|
||||||
[aw.update_card_positions() for aw in hud.aux_windows]
|
[aw.update_card_positions() for aw in hud.aux_windows]
|
||||||
hud.resize_windows()
|
hud.resize_windows()
|
||||||
except:
|
except:
|
||||||
log.exception("Error resizing HUD for table: %s." % hud.table.title)
|
log.exception(_("Error resizing HUD for table: %s.") % hud.table.title)
|
||||||
finally:
|
finally:
|
||||||
gtk.gdk.threads_leave()
|
gtk.gdk.threads_leave()
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ def idle_kill(hud_main, table):
|
||||||
del(hud_main.hud_dict[table])
|
del(hud_main.hud_dict[table])
|
||||||
hud_main.main_window.resize(1, 1)
|
hud_main.main_window.resize(1, 1)
|
||||||
except:
|
except:
|
||||||
log.exception("Error killing HUD for table: %s." % table.title)
|
log.exception(_("Error killing HUD for table: %s.") % table.title)
|
||||||
finally:
|
finally:
|
||||||
gtk.gdk.threads_leave()
|
gtk.gdk.threads_leave()
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ def idle_create(hud_main, new_hand_id, table, temp_key, max, poker_game, type, s
|
||||||
hud_main.hud_dict[temp_key].update(new_hand_id, hud_main.config)
|
hud_main.hud_dict[temp_key].update(new_hand_id, hud_main.config)
|
||||||
hud_main.hud_dict[temp_key].reposition_windows()
|
hud_main.hud_dict[temp_key].reposition_windows()
|
||||||
except:
|
except:
|
||||||
log.exception("Error creating HUD for hand %s." % new_hand_id)
|
log.exception(_("Error creating HUD for hand %s.") % new_hand_id)
|
||||||
finally:
|
finally:
|
||||||
gtk.gdk.threads_leave()
|
gtk.gdk.threads_leave()
|
||||||
return False
|
return False
|
||||||
|
@ -371,7 +371,7 @@ def idle_update(hud_main, new_hand_id, table_name, config):
|
||||||
hud_main.hud_dict[table_name].update(new_hand_id, config)
|
hud_main.hud_dict[table_name].update(new_hand_id, config)
|
||||||
[aw.update_gui(new_hand_id) for aw in hud_main.hud_dict[table_name].aux_windows]
|
[aw.update_gui(new_hand_id) for aw in hud_main.hud_dict[table_name].aux_windows]
|
||||||
except:
|
except:
|
||||||
log.exception("Error updating HUD for hand %s." % new_hand_id)
|
log.exception(_("Error updating HUD for hand %s.") % new_hand_id)
|
||||||
finally:
|
finally:
|
||||||
gtk.gdk.threads_leave()
|
gtk.gdk.threads_leave()
|
||||||
return False
|
return False
|
||||||
|
|
244
pyfpdb/IdentifySite.py
Normal file → Executable file
244
pyfpdb/IdentifySite.py
Normal file → Executable file
|
@ -1,122 +1,122 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
#Copyright 2010 Chaz Littlejohn
|
#Copyright 2010 Chaz Littlejohn
|
||||||
#This program is free software: you can redistribute it and/or modify
|
#This program is free software: you can redistribute it and/or modify
|
||||||
#it under the terms of the GNU Affero General Public License as published by
|
#it under the terms of the GNU Affero General Public License as published by
|
||||||
#the Free Software Foundation, version 3 of the License.
|
#the Free Software Foundation, version 3 of the License.
|
||||||
#
|
#
|
||||||
#This program is distributed in the hope that it will be useful,
|
#This program is distributed in the hope that it will be useful,
|
||||||
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
#GNU General Public License for more details.
|
#GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
#You should have received a copy of the GNU Affero General Public License
|
#You should have received a copy of the GNU Affero General Public License
|
||||||
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||||
|
|
||||||
import L10n
|
import L10n
|
||||||
_ = L10n.get_translation()
|
_ = L10n.get_translation()
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import codecs
|
import codecs
|
||||||
import Configuration
|
import Configuration
|
||||||
import Database
|
import Database
|
||||||
|
|
||||||
__ARCHIVE_PRE_HEADER_REGEX='^Hand #(\d+)\s*$|\*{20}\s#\s\d+\s\*+\s+'
|
__ARCHIVE_PRE_HEADER_REGEX='^Hand #(\d+)\s*$|\*{20}\s#\s\d+\s\*+\s+'
|
||||||
re_SplitArchive = re.compile(__ARCHIVE_PRE_HEADER_REGEX)
|
re_SplitArchive = re.compile(__ARCHIVE_PRE_HEADER_REGEX)
|
||||||
|
|
||||||
|
|
||||||
class IdentifySite:
|
class IdentifySite:
|
||||||
def __init__(self, config, in_path = '-'):
|
def __init__(self, config, in_path = '-'):
|
||||||
self.in_path = in_path
|
self.in_path = in_path
|
||||||
self.config = config
|
self.config = config
|
||||||
self.db = Database.Database(config)
|
self.db = Database.Database(config)
|
||||||
self.sitelist = {}
|
self.sitelist = {}
|
||||||
self.filelist = {}
|
self.filelist = {}
|
||||||
self.generateSiteList()
|
self.generateSiteList()
|
||||||
self.walkDirectory(self.in_path, self.sitelist)
|
self.walkDirectory(self.in_path, self.sitelist)
|
||||||
|
|
||||||
def generateSiteList(self):
|
def generateSiteList(self):
|
||||||
"""Generates a ordered dictionary of site, filter and filter name for each site in hhcs"""
|
"""Generates a ordered dictionary of site, filter and filter name for each site in hhcs"""
|
||||||
for site, hhc in self.config.hhcs.iteritems():
|
for site, hhc in self.config.hhcs.iteritems():
|
||||||
filter = hhc.converter
|
filter = hhc.converter
|
||||||
filter_name = filter.replace("ToFpdb", "")
|
filter_name = filter.replace("ToFpdb", "")
|
||||||
result = self.db.get_site_id(site)
|
result = self.db.get_site_id(site)
|
||||||
if len(result) == 1:
|
if len(result) == 1:
|
||||||
self.sitelist[result[0][0]] = (site, filter, filter_name)
|
self.sitelist[result[0][0]] = (site, filter, filter_name)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def walkDirectory(self, dir, sitelist):
|
def walkDirectory(self, dir, sitelist):
|
||||||
"""Walks a directory, and executes a callback on each file"""
|
"""Walks a directory, and executes a callback on each file"""
|
||||||
dir = os.path.abspath(dir)
|
dir = os.path.abspath(dir)
|
||||||
for file in [file for file in os.listdir(dir) if not file in [".",".."]]:
|
for file in [file for file in os.listdir(dir) if not file in [".",".."]]:
|
||||||
nfile = os.path.join(dir,file)
|
nfile = os.path.join(dir,file)
|
||||||
if os.path.isdir(nfile):
|
if os.path.isdir(nfile):
|
||||||
self.walkDirectory(nfile, sitelist)
|
self.walkDirectory(nfile, sitelist)
|
||||||
else:
|
else:
|
||||||
self.idSite(nfile, sitelist)
|
self.idSite(nfile, sitelist)
|
||||||
|
|
||||||
def __listof(self, x):
|
def __listof(self, x):
|
||||||
if isinstance(x, list) or isinstance(x, tuple):
|
if isinstance(x, list) or isinstance(x, tuple):
|
||||||
return x
|
return x
|
||||||
else:
|
else:
|
||||||
return [x]
|
return [x]
|
||||||
|
|
||||||
def idSite(self, file, sitelist):
|
def idSite(self, file, sitelist):
|
||||||
"""Identifies the site the hh file originated from"""
|
"""Identifies the site the hh file originated from"""
|
||||||
if file.endswith('.txt'):
|
if file.endswith('.txt'):
|
||||||
self.filelist[file] = ''
|
self.filelist[file] = ''
|
||||||
archive = False
|
archive = False
|
||||||
for site, info in sitelist.iteritems():
|
for site, info in sitelist.iteritems():
|
||||||
mod = __import__(info[1])
|
mod = __import__(info[1])
|
||||||
obj = getattr(mod, info[2], None)
|
obj = getattr(mod, info[2], None)
|
||||||
|
|
||||||
for kodec in self.__listof(obj.codepage):
|
for kodec in self.__listof(obj.codepage):
|
||||||
try:
|
try:
|
||||||
in_fh = codecs.open(file, 'r', kodec)
|
in_fh = codecs.open(file, 'r', kodec)
|
||||||
whole_file = in_fh.read()
|
whole_file = in_fh.read()
|
||||||
in_fh.close()
|
in_fh.close()
|
||||||
|
|
||||||
if info[2] in ('OnGame', 'Winamax'):
|
if info[2] in ('OnGame', 'Winamax'):
|
||||||
m = obj.re_HandInfo.search(whole_file)
|
m = obj.re_HandInfo.search(whole_file)
|
||||||
elif info[2] in ('PartyPoker'):
|
elif info[2] in ('PartyPoker'):
|
||||||
m = obj.re_GameInfoRing.search(whole_file)
|
m = obj.re_GameInfoRing.search(whole_file)
|
||||||
if not m:
|
if not m:
|
||||||
m = obj.re_GameInfoTrny.search(whole_file)
|
m = obj.re_GameInfoTrny.search(whole_file)
|
||||||
else:
|
else:
|
||||||
m = obj.re_GameInfo.search(whole_file)
|
m = obj.re_GameInfo.search(whole_file)
|
||||||
if re_SplitArchive.search(whole_file):
|
if re_SplitArchive.search(whole_file):
|
||||||
archive = True
|
archive = True
|
||||||
if m:
|
if m:
|
||||||
self.filelist[file] = [info[0]] + [info[1]] + [kodec] + [archive]
|
self.filelist[file] = [info[0]] + [info[1]] + [kodec] + [archive]
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv=None):
|
||||||
if argv is None:
|
if argv is None:
|
||||||
argv = sys.argv[1:]
|
argv = sys.argv[1:]
|
||||||
|
|
||||||
config = Configuration.Config(file = "HUD_config.test.xml")
|
config = Configuration.Config(file = "HUD_config.test.xml")
|
||||||
in_path = 'regression-test-files/'
|
in_path = 'regression-test-files/'
|
||||||
IdSite = IdentifySite(config, in_path)
|
IdSite = IdentifySite(config, in_path)
|
||||||
|
|
||||||
print "\n----------- SITE LIST -----------"
|
print "\n----------- SITE LIST -----------"
|
||||||
for site, info in IdSite.sitelist.iteritems():
|
for site, info in IdSite.sitelist.iteritems():
|
||||||
print site, info
|
print site, info
|
||||||
print "----------- END SITE LIST -----------"
|
print "----------- END SITE LIST -----------"
|
||||||
|
|
||||||
print "\n----------- ID REGRESSION FILES -----------"
|
print "\n----------- ID REGRESSION FILES -----------"
|
||||||
for file, site in IdSite.filelist.iteritems():
|
for file, site in IdSite.filelist.iteritems():
|
||||||
print file, site
|
print file, site
|
||||||
print "----------- END ID REGRESSION FILES -----------"
|
print "----------- END ID REGRESSION FILES -----------"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
|
@ -93,7 +93,7 @@ class OnGame(HandHistoryConverter):
|
||||||
(?P<CURRENCY>%(LS)s|)?(?P<SB>[.0-9]+)/
|
(?P<CURRENCY>%(LS)s|)?(?P<SB>[.0-9]+)/
|
||||||
(%(LS)s)?(?P<BB>[.0-9]+)
|
(%(LS)s)?(?P<BB>[.0-9]+)
|
||||||
)?
|
)?
|
||||||
""" % substitutions, re.MULTILINE|re.DOTALL|re.VERBOSE)
|
""" % substitutions, re.MULTILINE|re.DOTALL|re.VERBOSE) #TODO: detect play money (identified by "Play money" rather than "Real money" and set currency accordingly
|
||||||
|
|
||||||
re_TailSplitHands = re.compile(u'(\*\*\*\*\*\sEnd\sof\shand\s[-A-Z\d]+.*\n)(?=\*)')
|
re_TailSplitHands = re.compile(u'(\*\*\*\*\*\sEnd\sof\shand\s[-A-Z\d]+.*\n)(?=\*)')
|
||||||
re_Button = re.compile('Button: seat (?P<BUTTON>\d+)', re.MULTILINE) # Button: seat 2
|
re_Button = re.compile('Button: seat (?P<BUTTON>\d+)', re.MULTILINE) # Button: seat 2
|
||||||
|
@ -328,7 +328,7 @@ class OnGame(HandHistoryConverter):
|
||||||
def readAction(self, hand, street):
|
def readAction(self, hand, street):
|
||||||
m = self.re_Action.finditer(hand.streets[street])
|
m = self.re_Action.finditer(hand.streets[street])
|
||||||
for action in m:
|
for action in m:
|
||||||
acts = action.groupdict()
|
#acts = action.groupdict()
|
||||||
#log.debug("readaction: acts: %s" %acts)
|
#log.debug("readaction: acts: %s" %acts)
|
||||||
if action.group('ATYPE') == ' raises':
|
if action.group('ATYPE') == ' raises':
|
||||||
hand.addRaiseBy( street, action.group('PNAME'), action.group('BET') )
|
hand.addRaiseBy( street, action.group('PNAME'), action.group('BET') )
|
||||||
|
|
|
@ -123,7 +123,7 @@ import Configuration
|
||||||
import Exceptions
|
import Exceptions
|
||||||
import Stats
|
import Stats
|
||||||
|
|
||||||
VERSION = "0.21-rc1"
|
VERSION = "0.21-rc1 plus git"
|
||||||
|
|
||||||
|
|
||||||
class fpdb:
|
class fpdb:
|
||||||
|
@ -1094,7 +1094,7 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
|
||||||
self.add_and_display_tab(gv_tab, _("Tourney Graphs"))
|
self.add_and_display_tab(gv_tab, _("Tourney Graphs"))
|
||||||
|
|
||||||
def tabStove(self, widget, data=None):
|
def tabStove(self, widget, data=None):
|
||||||
"""opens a tab for bulk importing tournament summaries"""
|
"""opens a tab for poker stove"""
|
||||||
thread = GuiStove.GuiStove(self.config, self.window)
|
thread = GuiStove.GuiStove(self.config, self.window)
|
||||||
self.threads.append(thread)
|
self.threads.append(thread)
|
||||||
tab = thread.get_vbox()
|
tab = thread.get_vbox()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user