From c4d3789657b92bc876ff69f69b323ee2bae6781f Mon Sep 17 00:00:00 2001 From: grindi Date: Fri, 6 Nov 2009 23:47:31 +0300 Subject: [PATCH 1/4] Fixed: aux save layout doesn't work Bug maker, look at http://docs.python.org/tutorial/classes.html#generator-expressions (...for...) returns generator rather than tuple --- pyfpdb/Hud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index f0f47898..3ca6c33b 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -440,7 +440,7 @@ class Hud: new_layout[self.stat_windows[sw].adj - 1] = new_loc self.config.edit_layout(self.table.site, self.max, locations = new_layout) # ask each aux to save its layout back to the config object - (aux.save_layout() for aux in self.aux_windows) + [aux.save_layout() for aux in self.aux_windows] # save the config object back to the file print "saving new xml file" self.config.save() From fd085ecb4d049e51216e83c4d5d50976818df22a Mon Sep 17 00:00:00 2001 From: grindi Date: Sat, 7 Nov 2009 00:46:50 +0300 Subject: [PATCH 2/4] Fixed another aux bug --- pyfpdb/Hud.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 3ca6c33b..674b0a09 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -386,9 +386,9 @@ class Hud: (x, y) = loc[adj[i+1]] w.relocate(x, y) - # While we're at it, fix the positions of mucked cards too - for aux in self.aux_windows: - aux.update_card_positions() + # While we're at it, fix the positions of mucked cards too + for aux in self.aux_windows: + aux.update_card_positions() return True From 9dd600702aaa663b3671c168ec21ab8031de83a8 Mon Sep 17 00:00:00 2001 From: grindi Date: Sat, 7 Nov 2009 20:30:47 +0300 Subject: [PATCH 3/4] Moved window title re to HHC classes Just redefine function getTableTitleRe in coresponding hhc for custom re --- pyfpdb/HUD_main.py | 9 +++++---- pyfpdb/HandHistoryConverter.py | 23 +++++++++++++++++++++++ pyfpdb/TableWindow.py | 16 +++++++--------- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index e9fb40fb..48a412ee 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -53,6 +53,7 @@ import gobject # FreePokerTools modules import Configuration import Database +from HandHistoryConverter import getTableTitleRe # get the correct module for the current os if os.name == 'posix': import XTables as Tables @@ -253,10 +254,10 @@ class HUD_main(object): if comm_cards != {}: # stud! cards['common'] = comm_cards['common'] - if type == "tour": - tablewindow = Tables.Table(tournament = tour_number, table_number = tab_number) - else: - tablewindow = Tables.Table(table_name = table_name) + table_kwargs = dict(table_name = table_name, tournament = tour_number, table_number = tab_number) + search_string = getTableTitleRe(self.config, site, type, **table_kwargs) + tablewindow = Tables.Table(search_string, **table_kwargs) + if tablewindow is None: # If no client window is found on the screen, complain and continue if type == "tour": diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index bced9d93..53358d36 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -506,3 +506,26 @@ or None if we fail to get the info """ def getTourney(self): return self.tourney + + @staticmethod + def getTableTitleRe(type, table_name=None, tournament = None, table_number=None): + "Returns string to search in windows titles" + if type=="tour": + return "%s.+Table\s%s" % (tournament, table_number) + else: + return table_name + + + +def getTableTitleRe(config, sitename, *args, **kwargs): + "Returns string to search in windows titles for current site" + return getSiteHhc(config, sitename).getTableTitleRe(*args, **kwargs) + +def getSiteHhc(config, sitename): + "Returns HHC class for current site" + hhcName = config.supported_sites[sitename].converter + hhcModule = __import__(hhcName) + return getattr(hhcModule, hhcName[:-6]) + + + diff --git a/pyfpdb/TableWindow.py b/pyfpdb/TableWindow.py index bdc9db87..10607b16 100644 --- a/pyfpdb/TableWindow.py +++ b/pyfpdb/TableWindow.py @@ -93,19 +93,17 @@ gobject.signal_new("client_destroyed", gtk.Window, # screen location of (0, 0) in the working window. class Table_Window(object): - def __init__(self, table_name = None, tournament = None, table_number = None): + def __init__(self, search_string, table_name = None, tournament = None, table_number = None): - if table_name is not None: - search_string = table_name - self.name = table_name - self.tournament = None - self.table = None - elif tournament is not None and table_number is not None: + if tournament is not None and table_number is not None: print "tournament %s, table %s" % (tournament, table_number) self.tournament = int(tournament) self.table = int(table_number) self.name = "%s - %s" % (self.tournament, self.table) - search_string = "%s.+Table\s%s" % (tournament, table_number) + elif table_name is not None: + search_string = table_name + self.name = table_name + self.tournament = None else: return None @@ -151,4 +149,4 @@ class Table_Window(object): def check_bad_words(self, title): for word in bad_words: if word in title: return True - return False \ No newline at end of file + return False From dbaf4dbdbc639d9fe3ee225e60b69b5e80190ec5 Mon Sep 17 00:00:00 2001 From: grindi Date: Sat, 7 Nov 2009 21:57:23 +0300 Subject: [PATCH 4/4] Make msgs about parse errors more verbose + fix small bug in FpdbParseError --- pyfpdb/Exceptions.py | 4 ++-- pyfpdb/HandHistoryConverter.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Exceptions.py b/pyfpdb/Exceptions.py index eaf5d798..f7e9fa54 100644 --- a/pyfpdb/Exceptions.py +++ b/pyfpdb/Exceptions.py @@ -9,8 +9,8 @@ class FpdbParseError(FpdbError): self.value = value self.hid = hid def __str__(self): - if hid: - return repr("HID:"+hid+", "+self.value) + if self.hid: + return repr("HID:"+self.hid+", "+self.value) else: return repr(self.value) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 53358d36..6452cae4 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -154,6 +154,7 @@ Otherwise, finish at EOF. except FpdbParseError, e: numErrors += 1 log.warning("Failed to convert hand %s" % e.hid) + log.warning("Exception msg: '%s'" % str(e)) log.debug(handText) else: handsList = self.allHandsAsList() @@ -168,6 +169,7 @@ Otherwise, finish at EOF. except FpdbParseError, e: numErrors += 1 log.warning("Failed to convert hand %s" % e.hid) + log.warning("Exception msg: '%s'" % str(e)) log.debug(handText) numHands = len(handsList) endtime = time.time()