From 9413e74e0cddc12316620643e7e4a377abee0edf Mon Sep 17 00:00:00 2001 From: Steffen Schaumburg Date: Fri, 17 Dec 2010 19:09:28 +0100 Subject: [PATCH 01/21] add +git to version string again --- pyfpdb/fpdb.pyw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/fpdb.pyw b/pyfpdb/fpdb.pyw index 50823a93..13e90ce5 100755 --- a/pyfpdb/fpdb.pyw +++ b/pyfpdb/fpdb.pyw @@ -122,7 +122,7 @@ import Configuration import Exceptions import Stats -VERSION = "0.21-rc1" +VERSION = "0.21-rc1 plus git" class fpdb: From 147a40bff998ceb23fae7abf21d0af63b4ebda61 Mon Sep 17 00:00:00 2001 From: Steffen Schaumburg Date: Fri, 17 Dec 2010 19:13:33 +0100 Subject: [PATCH 02/21] gettextify warning --- pyfpdb/GuiSessionViewer.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pyfpdb/GuiSessionViewer.py b/pyfpdb/GuiSessionViewer.py index 6f0fd269..903c7fd1 100644 --- a/pyfpdb/GuiSessionViewer.py +++ b/pyfpdb/GuiSessionViewer.py @@ -157,15 +157,10 @@ class GuiSessionViewer (threading.Thread): # make sure Hand column is not displayed #[x for x in self.columns if x[0] == 'hand'][0][1] = False if DEBUG == False: - warning_string = """ -Session Viewer is proof of concept code only, and contains many bugs. - -Feel free to use the viewer, but there is no guarantee that the data is accurate. - -If you are interested in developing the code further please contact us via the usual channels. - -Thankyou -""" + warning_string = _("Session Viewer is proof of concept code only, and contains many bugs.\n") + 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") + warning_string += _("Thankyou") self.warning_box(warning_string) def warning_box(self, str, diatitle=_("FPDB WARNING")): From 43911a49e8620fe4e43bb97f5c721d2d4965ccf8 Mon Sep 17 00:00:00 2001 From: Steffen Schaumburg Date: Fri, 17 Dec 2010 19:16:11 +0100 Subject: [PATCH 03/21] split warning into several strings for easier translation --- pyfpdb/GuiStove.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pyfpdb/GuiStove.py b/pyfpdb/GuiStove.py index f238e503..b600c81e 100644 --- a/pyfpdb/GuiStove.py +++ b/pyfpdb/GuiStove.py @@ -54,15 +54,10 @@ class GuiStove(): self.mainHBox.show_all() if DEBUG == False: - warning_string = _(""" -Stove is a GUI mockup of a EV calculation page, and completely non functional. - -Unless you are interested in developing this feature, please ignore this page. - -If you are interested in developing the code further see GuiStove.py and Stove.py - -Thankyou -""") + warning_string = _("Stove is a GUI mockup of a EV calculation page, and completely non functional.\n") + 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") + warning_string = _("Thank you\n") self.warning_box(warning_string) From 3157cf3c15211f0b8a0142670e7c3261271d1b7d Mon Sep 17 00:00:00 2001 From: Steffen Schaumburg Date: Fri, 17 Dec 2010 19:18:52 +0100 Subject: [PATCH 04/21] correct comment --- pyfpdb/fpdb.pyw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/fpdb.pyw b/pyfpdb/fpdb.pyw index 6dc2feb2..1cdb7783 100755 --- a/pyfpdb/fpdb.pyw +++ b/pyfpdb/fpdb.pyw @@ -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")) 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) self.threads.append(thread) tab = thread.get_vbox() From 185aa5af3ebb9f74f04388ea2282e70632ab5796 Mon Sep 17 00:00:00 2001 From: Steffen Schaumburg Date: Sat, 18 Dec 2010 20:32:24 +0100 Subject: [PATCH 05/21] tiny cosmetic change to prints --- pyfpdb/GuiReplayer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyfpdb/GuiReplayer.py b/pyfpdb/GuiReplayer.py index 4b95faf2..6cdf326b 100644 --- a/pyfpdb/GuiReplayer.py +++ b/pyfpdb/GuiReplayer.py @@ -108,11 +108,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 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] - print "holecards",self.table[i]['holecards'] + print "holecards: ",self.table[i]['holecards'] except: self.table[i]['holecards']='' 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 From 51ff6d0bb0dfa9ab30f7df24003c6aa198fed18e Mon Sep 17 00:00:00 2001 From: Steffen Schaumburg Date: Sat, 18 Dec 2010 20:33:22 +0100 Subject: [PATCH 06/21] another trivial cosmetic change to guireplayer --- pyfpdb/GuiReplayer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/GuiReplayer.py b/pyfpdb/GuiReplayer.py index 6cdf326b..f9269b8e 100644 --- a/pyfpdb/GuiReplayer.py +++ b/pyfpdb/GuiReplayer.py @@ -226,7 +226,7 @@ class GuiReplayer: rect = gtk.gdk.Rectangle(270,270,100,50) self.area.window.invalidate_rect(rect, True) #refresh pot area 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 From 86150294ec917cbd3804c27b9a7259bacd7597da Mon Sep 17 00:00:00 2001 From: Steffen Schaumburg Date: Sat, 18 Dec 2010 21:28:01 +0100 Subject: [PATCH 07/21] some gettextifications --- pyfpdb/Database.py | 4 ++-- pyfpdb/HUD_main.pyw | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index fa23f1cd..943479cd 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -1694,11 +1694,11 @@ class Database: def storeHand(self, p, printdata = False): if printdata: - print "######## Hands ##########" + print _("######## Hands ##########") import pprint pp = pprint.PrettyPrinter(indent=4) pp.pprint(p) - print "###### End Hands ########" + print _("###### End Hands ########") #stores into table hands: q = self.sql.query['store_hand'] diff --git a/pyfpdb/HUD_main.pyw b/pyfpdb/HUD_main.pyw index 79b2fbfe..9c50bcb4 100755 --- a/pyfpdb/HUD_main.pyw +++ b/pyfpdb/HUD_main.pyw @@ -321,7 +321,7 @@ def idle_resize(hud): [aw.update_card_positions() for aw in hud.aux_windows] hud.resize_windows() except: - log.exception("Error resizing HUD for table: %s." % hud.table.title) + log.exception(_("Error resizing HUD for table: %s.") % hud.table.title) finally: gtk.gdk.threads_leave() @@ -335,7 +335,7 @@ def idle_kill(hud_main, table): del(hud_main.hud_dict[table]) hud_main.main_window.resize(1, 1) except: - log.exception("Error killing HUD for table: %s." % table.title) + log.exception(_("Error killing HUD for table: %s.") % table.title) finally: gtk.gdk.threads_leave() @@ -358,7 +358,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].reposition_windows() except: - log.exception("Error creating HUD for hand %s." % new_hand_id) + log.exception(_("Error creating HUD for hand %s.") % new_hand_id) finally: gtk.gdk.threads_leave() return False @@ -369,7 +369,7 @@ def idle_update(hud_main, new_hand_id, table_name, 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] except: - log.exception("Error updating HUD for hand %s." % new_hand_id) + log.exception(_("Error updating HUD for hand %s.") % new_hand_id) finally: gtk.gdk.threads_leave() return False From 2eb51d060734d3b4372c14c6d8bcd92c55d9f271 Mon Sep 17 00:00:00 2001 From: Steffen Schaumburg Date: Sun, 19 Dec 2010 04:10:08 +0100 Subject: [PATCH 08/21] change line ending on IdentifySite to unix and make it executable --- pyfpdb/IdentifySite.py | 244 ++++++++++++++++++++--------------------- 1 file changed, 122 insertions(+), 122 deletions(-) mode change 100644 => 100755 pyfpdb/IdentifySite.py diff --git a/pyfpdb/IdentifySite.py b/pyfpdb/IdentifySite.py old mode 100644 new mode 100755 index b4f1a8a7..26a3e1e2 --- a/pyfpdb/IdentifySite.py +++ b/pyfpdb/IdentifySite.py @@ -1,122 +1,122 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -#Copyright 2010 Chaz Littlejohn -#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 -#the Free Software Foundation, version 3 of the License. -# -#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 Affero General Public License -#along with this program. If not, see . -#In the "official" distribution you can find the license in agpl-3.0.txt. - -import L10n -_ = L10n.get_translation() - -import re -import sys -import os -import os.path -from optparse import OptionParser -import codecs -import Configuration -import Database - -__ARCHIVE_PRE_HEADER_REGEX='^Hand #(\d+)\s*$|\*{20}\s#\s\d+\s\*+\s+' -re_SplitArchive = re.compile(__ARCHIVE_PRE_HEADER_REGEX) - - -class IdentifySite: - def __init__(self, config, in_path = '-'): - self.in_path = in_path - self.config = config - self.db = Database.Database(config) - self.sitelist = {} - self.filelist = {} - self.generateSiteList() - self.walkDirectory(self.in_path, self.sitelist) - - def generateSiteList(self): - """Generates a ordered dictionary of site, filter and filter name for each site in hhcs""" - for site, hhc in self.config.hhcs.iteritems(): - filter = hhc.converter - filter_name = filter.replace("ToFpdb", "") - result = self.db.get_site_id(site) - if len(result) == 1: - self.sitelist[result[0][0]] = (site, filter, filter_name) - else: - pass - - def walkDirectory(self, dir, sitelist): - """Walks a directory, and executes a callback on each file""" - dir = os.path.abspath(dir) - for file in [file for file in os.listdir(dir) if not file in [".",".."]]: - nfile = os.path.join(dir,file) - if os.path.isdir(nfile): - self.walkDirectory(nfile, sitelist) - else: - self.idSite(nfile, sitelist) - - def __listof(self, x): - if isinstance(x, list) or isinstance(x, tuple): - return x - else: - return [x] - - def idSite(self, file, sitelist): - """Identifies the site the hh file originated from""" - if file.endswith('.txt'): - self.filelist[file] = '' - archive = False - for site, info in sitelist.iteritems(): - mod = __import__(info[1]) - obj = getattr(mod, info[2], None) - - for kodec in self.__listof(obj.codepage): - try: - in_fh = codecs.open(file, 'r', kodec) - whole_file = in_fh.read() - in_fh.close() - - if info[2] in ('OnGame', 'Winamax'): - m = obj.re_HandInfo.search(whole_file) - elif info[2] in ('PartyPoker'): - m = obj.re_GameInfoRing.search(whole_file) - if not m: - m = obj.re_GameInfoTrny.search(whole_file) - else: - m = obj.re_GameInfo.search(whole_file) - if re_SplitArchive.search(whole_file): - archive = True - if m: - self.filelist[file] = [info[0]] + [info[1]] + [kodec] + [archive] - break - except: - pass - -def main(argv=None): - if argv is None: - argv = sys.argv[1:] - - config = Configuration.Config(file = "HUD_config.test.xml") - in_path = 'regression-test-files/' - IdSite = IdentifySite(config, in_path) - - print "\n----------- SITE LIST -----------" - for site, info in IdSite.sitelist.iteritems(): - print site, info - print "----------- END SITE LIST -----------" - - print "\n----------- ID REGRESSION FILES -----------" - for file, site in IdSite.filelist.iteritems(): - print file, site - print "----------- END ID REGRESSION FILES -----------" - - -if __name__ == '__main__': - sys.exit(main()) +#!/usr/bin/python +# -*- coding: utf-8 -*- + +#Copyright 2010 Chaz Littlejohn +#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 +#the Free Software Foundation, version 3 of the License. +# +#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 Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in agpl-3.0.txt. + +import L10n +_ = L10n.get_translation() + +import re +import sys +import os +import os.path +from optparse import OptionParser +import codecs +import Configuration +import Database + +__ARCHIVE_PRE_HEADER_REGEX='^Hand #(\d+)\s*$|\*{20}\s#\s\d+\s\*+\s+' +re_SplitArchive = re.compile(__ARCHIVE_PRE_HEADER_REGEX) + + +class IdentifySite: + def __init__(self, config, in_path = '-'): + self.in_path = in_path + self.config = config + self.db = Database.Database(config) + self.sitelist = {} + self.filelist = {} + self.generateSiteList() + self.walkDirectory(self.in_path, self.sitelist) + + def generateSiteList(self): + """Generates a ordered dictionary of site, filter and filter name for each site in hhcs""" + for site, hhc in self.config.hhcs.iteritems(): + filter = hhc.converter + filter_name = filter.replace("ToFpdb", "") + result = self.db.get_site_id(site) + if len(result) == 1: + self.sitelist[result[0][0]] = (site, filter, filter_name) + else: + pass + + def walkDirectory(self, dir, sitelist): + """Walks a directory, and executes a callback on each file""" + dir = os.path.abspath(dir) + for file in [file for file in os.listdir(dir) if not file in [".",".."]]: + nfile = os.path.join(dir,file) + if os.path.isdir(nfile): + self.walkDirectory(nfile, sitelist) + else: + self.idSite(nfile, sitelist) + + def __listof(self, x): + if isinstance(x, list) or isinstance(x, tuple): + return x + else: + return [x] + + def idSite(self, file, sitelist): + """Identifies the site the hh file originated from""" + if file.endswith('.txt'): + self.filelist[file] = '' + archive = False + for site, info in sitelist.iteritems(): + mod = __import__(info[1]) + obj = getattr(mod, info[2], None) + + for kodec in self.__listof(obj.codepage): + try: + in_fh = codecs.open(file, 'r', kodec) + whole_file = in_fh.read() + in_fh.close() + + if info[2] in ('OnGame', 'Winamax'): + m = obj.re_HandInfo.search(whole_file) + elif info[2] in ('PartyPoker'): + m = obj.re_GameInfoRing.search(whole_file) + if not m: + m = obj.re_GameInfoTrny.search(whole_file) + else: + m = obj.re_GameInfo.search(whole_file) + if re_SplitArchive.search(whole_file): + archive = True + if m: + self.filelist[file] = [info[0]] + [info[1]] + [kodec] + [archive] + break + except: + pass + +def main(argv=None): + if argv is None: + argv = sys.argv[1:] + + config = Configuration.Config(file = "HUD_config.test.xml") + in_path = 'regression-test-files/' + IdSite = IdentifySite(config, in_path) + + print "\n----------- SITE LIST -----------" + for site, info in IdSite.sitelist.iteritems(): + print site, info + print "----------- END SITE LIST -----------" + + print "\n----------- ID REGRESSION FILES -----------" + for file, site in IdSite.filelist.iteritems(): + print file, site + print "----------- END ID REGRESSION FILES -----------" + + +if __name__ == '__main__': + sys.exit(main()) From 573a2fad886280bc393d3eaf45748c8340566dcc Mon Sep 17 00:00:00 2001 From: Steffen Schaumburg Date: Sun, 19 Dec 2010 04:29:00 +0100 Subject: [PATCH 09/21] make ongame work with EUR --- pyfpdb/OnGameToFpdb.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyfpdb/OnGameToFpdb.py b/pyfpdb/OnGameToFpdb.py index faf52522..6f6c7c54 100755 --- a/pyfpdb/OnGameToFpdb.py +++ b/pyfpdb/OnGameToFpdb.py @@ -92,7 +92,7 @@ class OnGame(HandHistoryConverter): (%(LS)s)?(?P[.0-9]+)/ (%(LS)s)?(?P[.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_Button = re.compile('Button: seat (?P