From f12bc7bfaa399880627f240583d2098d2b99894a Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 7 Jan 2011 13:58:15 +0800 Subject: [PATCH] Add printdata capability for Gametype info. --- pyfpdb/Database.py | 16 ++++++++++++---- pyfpdb/Hand.py | 4 ++-- pyfpdb/fpdb_import.py | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 8ed0e3bc..e3a8e82e 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -2169,7 +2169,7 @@ class Database: dup = True return dup - def getGameTypeId(self, siteid, game): + def getGameTypeId(self, siteid, game, printdata = False): c = self.get_cursor() #FIXME: Fixed for NL at the moment c.execute(self.sql.query['getGametypeNL'], (siteid, game['type'], game['category'], game['limitType'], game['currency'], @@ -2181,14 +2181,22 @@ class Database: hilo = "s" elif game['category'] in ['razz','27_3draw','badugi', '27_1draw']: hilo = "l" + #FIXME: recognise currency + #TODO: this wont work for non-standard structures tmp = self.insertGameTypes( (siteid, game['currency'], game['type'], game['base'], game['category'], game['limitType'], hilo, int(Decimal(game['sb'])*100), int(Decimal(game['bb'])*100), - int(Decimal(game['bb'])*100), int(Decimal(game['bb'])*200)) ) #TODO: this wont work for non-standard structures - #FIXME: recognise currency + int(Decimal(game['bb'])*100), int(Decimal(game['bb'])*200)), printdata = printdata) return tmp[0] - def insertGameTypes(self, row): + def insertGameTypes(self, row, printdata = False): + if printdata: + print _("######## Gametype ##########") + import pprint + pp = pprint.PrettyPrinter(indent=4) + pp.pprint(row) + print _("###### End Gametype ########") + c = self.get_cursor() c.execute( self.sql.query['insertGameTypes'], row ) return [self.get_last_insert_id(c)] diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 405a56e5..0556cc9e 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -226,7 +226,7 @@ dealt whether they were seen in a 'dealt to' line self.holecards[street][player] = [open, closed] - def prepInsert(self, db): + def prepInsert(self, db, printtest = False): ##### # Players, Gametypes, TourneyTypes are all shared functions that are needed for additional tables # These functions are intended for prep insert eventually @@ -235,7 +235,7 @@ dealt whether they were seen in a 'dealt to' line self.dbid_pids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId) #Gametypes - self.dbid_gt = db.getGameTypeId(self.siteId, self.gametype) + self.dbid_gt = db.getGameTypeId(self.siteId, self.gametype, printdata = printtest) if self.tourNo!=None: self.tourneyTypeId = db.createTourneyType(self) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index ba1251ac..5fb43632 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -477,7 +477,7 @@ class Importer: for hand in handlist: if hand is not None: - hand.prepInsert(self.database) + hand.prepInsert(self.database, printtest = self.settings['testData']) try: hand.insert(self.database, printtest = self.settings['testData']) except Exceptions.FpdbHandDuplicate: