diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 533bf86e..0647baf2 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -1068,43 +1068,43 @@ class Database: if cons: pass else: - print _("creating foreign key "), fk['fktab'], fk['fkcol'], "->", fk['rtab'], fk['rcol'] + print _("Creating foreign key "), fk['fktab'], fk['fkcol'], "->", fk['rtab'], fk['rcol'] try: c.execute("alter table " + fk['fktab'] + " add foreign key (" + fk['fkcol'] + ") references " + fk['rtab'] + "(" + fk['rcol'] + ")") except: - print _(" create foreign key failed: ") + str(sys.exc_info()) + print _("Create foreign key failed: ") + str(sys.exc_info()) elif self.backend == self.PGSQL: - print _("creating foreign key "), fk['fktab'], fk['fkcol'], "->", fk['rtab'], fk['rcol'] + print _("Creating foreign key "), fk['fktab'], fk['fkcol'], "->", fk['rtab'], fk['rcol'] try: c.execute("alter table " + fk['fktab'] + " add constraint " + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' + " foreign key (" + fk['fkcol'] + ") references " + fk['rtab'] + "(" + fk['rcol'] + ")") except: - print _(" create foreign key failed: ") + str(sys.exc_info()) + print _("Create foreign key failed: ") + str(sys.exc_info()) else: return -1 for idx in self.indexes[self.backend]: if idx['drop'] == 1: if self.backend == self.MYSQL_INNODB: - print _("creating mysql index "), idx['tab'], idx['col'] + print _("Creating mysql index %s %s") % (idx['tab'], idx['col']) try: s = "alter table %s add index %s(%s)" % (idx['tab'],idx['col'],idx['col']) c.execute(s) except: - print _(" create foreign key failed: ") + str(sys.exc_info()) + print _("Create foreign key failed: ") + str(sys.exc_info()) elif self.backend == self.PGSQL: # pass # mod to use tab_col for index name? - print _("creating pg index "), idx['tab'], idx['col'] + print _("Creating pg index "), idx['tab'], idx['col'] try: s = "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col']) c.execute(s) except: - print _(" create index failed: ") + str(sys.exc_info()) + print _("Create index failed: ") + str(sys.exc_info()) else: return -1 @@ -1253,7 +1253,7 @@ class Database: s = "create index %s on %s(%s)" % (idx['col'],idx['tab'],idx['col']) self.get_cursor().execute(s) except: - print _(" create index failed: ") + str(sys.exc_info()) + print _("Create index failed: ") + str(sys.exc_info()) elif self.backend == self.PGSQL: # mod to use tab_col for index name? print _("Creating pgsql index %s %s") %(idx['tab'], idx['col']) @@ -1262,7 +1262,7 @@ class Database: s = "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col']) self.get_cursor().execute(s) except: - print _(" create index failed: ") + str(sys.exc_info()) + print _("Create index failed: ") + str(sys.exc_info()) elif self.backend == self.SQLITE: print _("Creating sqlite index %s %s") %(idx['tab'], idx['col']) log.debug(_("Creating sqlite index %s %s") %(idx['tab'], idx['col'])) @@ -1278,7 +1278,7 @@ class Database: self.connection.set_isolation_level(1) # go back to normal isolation level except: print _("Error creating indexes: ") + str(sys.exc_value) - raise FpdbError( "Error creating indexes " + str(sys.exc_value) ) + raise FpdbError("Error creating indexes: " + str(sys.exc_value) ) #end def createAllIndexes def dropAllIndexes(self): diff --git a/pyfpdb/GuiRingPlayerStats.py b/pyfpdb/GuiRingPlayerStats.py index 3d1bcb21..0d40fd59 100644 --- a/pyfpdb/GuiRingPlayerStats.py +++ b/pyfpdb/GuiRingPlayerStats.py @@ -41,33 +41,33 @@ from TreeViewTooltips import TreeViewTooltips #new order in config file: colalias,colheading,colshowsumm,colshowposn,colformat,coltype,colxalign = 0,1,2,3,4,5,6 ranks = {'x':0, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'T':10, 'J':11, 'Q':12, 'K':13, 'A':14} -onlinehelp = {'Game':'Type of Game', - 'Hand':'Hole cards', - 'Posn':'Position', - 'Name':'Name of the player', - 'Hds':'Number of hands played', - 'Seats':'Number of Seats', - 'VPIP':'Voluntarily Putting In the pot\n(blinds excluded)', - 'PFR':'% Pre Flop Raise', - 'PF3':'% Pre Flop Re-Raise / 3Bet', - 'AggFac':'Aggression Factor\n', - 'AggFreq':'Aggression Frequency\nBet or Raise vs Fold', - 'ContBet':'Continuation Bet on the flop', - 'RFI':'% Raise First In\% Raise when first to bet', - 'Steals':'% First to raise pre-flop\nand steal blinds', - 'Saw_F':'% Saw Flop vs hands dealt', - 'SawSD':'Saw Show Down / River', - 'WtSDwsF':'Went To Show Down When Saw Flop', - 'W$SD':'Amount Won when Show Down seen', - 'FlAFq':'Flop Aggression\n% Bet or Raise after seeing Flop', - 'TuAFq':'Turn Aggression\n% Bet or Raise after seeing Turn', - 'RvAFq':'River Aggression\n% Bet or Raise after seeing River', - 'PoFAFq':'Coming Soon\nTotal % agression', - 'Net($)':'Amount won', - 'bb/100':'Number of Big Blinds won\nor lost per 100 hands', - 'Rake($)':'Amount of rake paid', - 'bbxr/100':'Number of Big Blinds won\nor lost per 100 hands\nwhen excluding rake', - 'Variance':'Measure of uncertainty\nThe lower, the more stable the amounts won' +onlinehelp = {'Game':_('Type of Game'), + 'Hand':_('Hole cards'), + 'Posn':_('Position'), + 'Name':_('Name of the player'), + 'Hds':_('Number of hands played'), + 'Seats':_('Number of Seats'), + 'VPIP':_('Voluntarily Putting In the pot\n(blinds excluded)'), + 'PFR':_('% Pre Flop Raise'), + 'PF3':_('% Pre Flop Re-Raise / 3Bet'), + 'AggFac':_('Aggression Factor\n'), + 'AggFreq':_('Aggression Frequency\nBet or Raise vs Fold'), + 'ContBet':_('Continuation Bet on the flop'), + 'RFI':_('% Raise First In\% Raise when first to bet'), + 'Steals':_('% First to raise pre-flop\nand steal blinds'), + 'Saw_F':_('% Saw Flop vs hands dealt'), + 'SawSD':_('Saw Show Down / River'), + 'WtSDwsF':_('Went To Show Down When Saw Flop'), + 'W$SD':_('Amount Won when Show Down seen'), + 'FlAFq':_('Flop Aggression\n% Bet or Raise after seeing Flop'), + 'TuAFq':_('Turn Aggression\n% Bet or Raise after seeing Turn'), + 'RvAFq':_('River Aggression\n% Bet or Raise after seeing River'), + 'PoFAFq':_('Coming Soon\nTotal % agression'), + 'Net($)':_('Amount won'), + 'bb/100':_('Number of Big Blinds won\nor lost per 100 hands'), + 'Rake($)':_('Amount of rake paid'), + 'bbxr/100':_('Number of Big Blinds won\nor lost per 100 hands\nwhen excluding rake'), + 'Variance':_('Measure of uncertainty\nThe lower, the more stable the amounts won') } @@ -85,9 +85,9 @@ class DemoTips(TreeViewTooltips): def get_tooltip(self, view, column, path): model = view.get_model() cards = model[path][0] - title=column.get_title() - display='%s\n%s' % (title,onlinehelp[title]) + if (title == 'Hand' or title == 'Game'): display='' #no tooltips on headers + else: display='%s for %s\n%s' % (title,cards,onlinehelp[title]) return (display) def location(self, x, y, w, h): diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 0909d42d..ce0e4e7a 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -281,9 +281,143 @@ db: a connected Database object""" def select(self, handId): """ Function to create Hand object from database """ + c = cnxn.cursor() + + # We need at least sitename, gametype, handid + # for the Hand.__init__ + c.execute("""SELECT + s.name, + g.category, + g.base, + g.type, + g.limitType, + g.hilo, + round(g.smallBlind / 100.0,2), + round(g.bigBlind / 100.0,2), + round(g.smallBet / 100.0,2), + round(g.bigBet / 100.0,2), + s.currency, + h.boardcard1, + h.boardcard2, + h.boardcard3, + h.boardcard4, + h.boardcard5 + FROM + hands as h, + sites as s, + gametypes as g, + handsplayers as hp, + players as p + WHERE + h.id = %(handid)s + and g.id = h.gametypeid + and hp.handid = h.id + and p.id = hp.playerid + and s.id = p.siteid + limit 1""", {'handid':handid}) + #TODO: siteid should be in hands table - we took the scenic route through players here. + res = c.fetchone() + gametype = {'category':res[1],'base':res[2],'type':res[3],'limitType':res[4],'hilo':res[5],'sb':res[6],'bb':res[7], 'currency':res[10]} + c = Configuration.Config() + h = HoldemOmahaHand(config = c, hhc = None, sitename=res[0], gametype = gametype, handText=None, builtFrom = "DB", handid=handid) + cards = map(Card.valueSuitFromCard, res[11:16] ) + if cards[0]: + h.setCommunityCards('FLOP', cards[0:3]) + if cards[3]: + h.setCommunityCards('TURN', [cards[3]]) + if cards[4]: + h.setCommunityCards('RIVER', [cards[4]]) + #[Card.valueSuitFromCard(x) for x in cards] + + # HandInfo : HID, TABLE + # BUTTON - why is this treated specially in Hand? + # answer: it is written out in hand histories + # still, I think we should record all the active seat positions in a seat_order array + c.execute("""SELECT + h.sitehandno as hid, + h.tablename as table, + h.startTime as startTime + FROM + hands as h + WHERE h.id = %(handid)s + """, {'handid':handid}) + res = c.fetchone() + h.handid = res[0] + h.tablename = res[1] + h.startTime = res[2] # automatically a datetime + + # PlayerStacks + c.execute("""SELECT + hp.seatno, + round(hp.winnings / 100.0,2) as winnings, + p.name, + round(hp.startcash / 100.0,2) as chips, + hp.card1,hp.card2, + hp.position + FROM + handsplayers as hp, + players as p + WHERE + hp.handid = %(handid)s + and p.id = hp.playerid + """, {'handid':handid}) + for (seat, winnings, name, chips, card1,card2, position) in c.fetchall(): + h.addPlayer(seat,name,chips) + if card1 and card2: + h.addHoleCards(map(Card.valueSuitFromCard, (card1,card2)), name, dealt=True) + if winnings > 0: + h.addCollectPot(name, winnings) + if position == 'B': + h.buttonpos = seat + # actions + c.execute("""SELECT + (ha.street,ha.actionno) as actnum, + p.name, + ha.street, + ha.action, + ha.allin, + round(ha.amount / 100.0,2) + FROM + handsplayers as hp, + handsactions as ha, + players as p + WHERE + hp.handid = %(handid)s + and ha.handsplayerid = hp.id + and p.id = hp.playerid + ORDER BY + ha.street,ha.actionno + """, {'handid':handid}) + res = c.fetchall() + for (actnum,player, streetnum, act, allin, amount) in res: + act=act.strip() + street = h.allStreets[streetnum+1] + if act==u'blind': + h.addBlind(player, 'big blind', amount) + # TODO: The type of blind is not recorded in the DB. + # TODO: preflop street name anomalies in Hand + elif act==u'fold': + h.addFold(street,player) + elif act==u'call': + h.addCall(street,player,amount) + elif act==u'bet': + h.addBet(street,player,amount) + elif act==u'check': + h.addCheck(street,player) + elif act==u'unbet': + pass + else: + print act, player, streetnum, allin, amount + # TODO : other actions + #hhc.readShowdownActions(self) + #hc.readShownCards(self) + h.totalPot() + h.rake = h.totalpot - h.totalcollected + + return h def addPlayer(self, seat, name, chips): """\ @@ -1540,146 +1674,4 @@ class Pot(object): return ret + ''.join([ (" Side pot %s%.2f." % (self.sym, self.pots[x]) ) for x in xrange(1, len(self.pots)) ]) -def assemble(cnxn, handid): - c = cnxn.cursor() - # We need at least sitename, gametype, handid - # for the Hand.__init__ - c.execute(""" -select - s.name, - g.category, - g.base, - g.type, - g.limitType, - g.hilo, - round(g.smallBlind / 100.0,2), - round(g.bigBlind / 100.0,2), - round(g.smallBet / 100.0,2), - round(g.bigBet / 100.0,2), - s.currency, - h.boardcard1, - h.boardcard2, - h.boardcard3, - h.boardcard4, - h.boardcard5 -from - hands as h, - sites as s, - gametypes as g, - handsplayers as hp, - players as p -where - h.id = %(handid)s -and g.id = h.gametypeid -and hp.handid = h.id -and p.id = hp.playerid -and s.id = p.siteid -limit 1""", {'handid':handid}) - #TODO: siteid should be in hands table - we took the scenic route through players here. - res = c.fetchone() - gametype = {'category':res[1],'base':res[2],'type':res[3],'limitType':res[4],'hilo':res[5],'sb':res[6],'bb':res[7], 'currency':res[10]} - c = Configuration.Config() - h = HoldemOmahaHand(config = c, hhc = None, sitename=res[0], gametype = gametype, handText=None, builtFrom = "DB", handid=handid) - cards = map(Card.valueSuitFromCard, res[11:16] ) - if cards[0]: - h.setCommunityCards('FLOP', cards[0:3]) - if cards[3]: - h.setCommunityCards('TURN', [cards[3]]) - if cards[4]: - h.setCommunityCards('RIVER', [cards[4]]) - #[Card.valueSuitFromCard(x) for x in cards] - - # HandInfo : HID, TABLE - # BUTTON - why is this treated specially in Hand? - # answer: it is written out in hand histories - # still, I think we should record all the active seat positions in a seat_order array - c.execute(""" -SELECT - h.sitehandno as hid, - h.tablename as table, - h.startTime as startTime -FROM - hands as h -WHERE h.id = %(handid)s -""", {'handid':handid}) - res = c.fetchone() - h.handid = res[0] - h.tablename = res[1] - h.startTime = res[2] # automatically a datetime - - # PlayerStacks - c.execute(""" -SELECT - hp.seatno, - round(hp.winnings / 100.0,2) as winnings, - p.name, - round(hp.startcash / 100.0,2) as chips, - hp.card1,hp.card2, - hp.position -FROM - handsplayers as hp, - players as p -WHERE - hp.handid = %(handid)s -and p.id = hp.playerid -""", {'handid':handid}) - for (seat, winnings, name, chips, card1,card2, position) in c.fetchall(): - h.addPlayer(seat,name,chips) - if card1 and card2: - h.addHoleCards(map(Card.valueSuitFromCard, (card1,card2)), name, dealt=True) - if winnings > 0: - h.addCollectPot(name, winnings) - if position == 'B': - h.buttonpos = seat - - - # actions - c.execute(""" -SELECT - (ha.street,ha.actionno) as actnum, - p.name, - ha.street, - ha.action, - ha.allin, - round(ha.amount / 100.0,2) -FROM - handsplayers as hp, - handsactions as ha, - players as p -WHERE - hp.handid = %(handid)s -and ha.handsplayerid = hp.id -and p.id = hp.playerid -ORDER BY - ha.street,ha.actionno -""", {'handid':handid}) - res = c.fetchall() - for (actnum,player, streetnum, act, allin, amount) in res: - act=act.strip() - street = h.allStreets[streetnum+1] - if act==u'blind': - h.addBlind(player, 'big blind', amount) - # TODO: The type of blind is not recorded in the DB. - # TODO: preflop street name anomalies in Hand - elif act==u'fold': - h.addFold(street,player) - elif act==u'call': - h.addCall(street,player,amount) - elif act==u'bet': - h.addBet(street,player,amount) - elif act==u'check': - h.addCheck(street,player) - elif act==u'unbet': - pass - else: - print act, player, streetnum, allin, amount - # TODO : other actions - - #hhc.readShowdownActions(self) - #hc.readShownCards(self) - h.totalPot() - h.rake = h.totalpot - h.totalcollected - - - return h diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 8b35c525..24719de5 100644 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -39,7 +39,7 @@ class PokerStars(HandHistoryConverter): siteId = 2 # Needs to match id entry in Sites database mixes = { 'HORSE': 'horse', '8-Game': '8game', 'HOSE': 'hose'} # Legal mixed games - sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\xe2\x82\xac", "GBP": "\xa3"} # ADD Euro, Sterling, etc HERE + sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\xe2\x82\xac", "GBP": "\xa3", "play": ""} # ADD Euro, Sterling, etc HERE substitutions = { 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes 'LS' : "\$|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8) diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 59361490..eef9ce04 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -3055,8 +3055,6 @@ class Sql: order by stats.category, stats.limitType, stats.bigBlindDesc desc , cast(stats.PlPosition as smallint) """ - #elif db_server == 'sqlite': - # self.query['playerStatsByPosition'] = """ """ #################################### # Cash Game Graph query diff --git a/pyfpdb/TreeViewTooltips.py b/pyfpdb/TreeViewTooltips.py index 1112d3e4..9b891708 100644 --- a/pyfpdb/TreeViewTooltips.py +++ b/pyfpdb/TreeViewTooltips.py @@ -24,6 +24,7 @@ # # dpopowich AT astro dot umass dot edu # +# This version of the file is part of fpdb, contact: fpdb-main@lists.sourceforge.net ''' TreeViewTooltips.py @@ -104,7 +105,7 @@ import gobject if gtk.gtk_version < (2, 8): import warnings - msg = ('''This module was developed and tested with version 2.8.18 of gtk. You are using version %d.%d.%d. Your milage may vary.''' + msg = (_('''This module was developed and tested with version 2.8.18 of gtk. You are using version %d.%d.%d. Your milage may vary.''') % gtk.gtk_version) warnings.warn(msg) diff --git a/pyfpdb/WinamaxToFpdb.py b/pyfpdb/WinamaxToFpdb.py index 77202167..c49f4e09 100644 --- a/pyfpdb/WinamaxToFpdb.py +++ b/pyfpdb/WinamaxToFpdb.py @@ -213,7 +213,7 @@ class Winamax(HandHistoryConverter): hand.mixed = None def readPlayerStacks(self, hand): - log.debug("readplayerstacks: re is '%s'" % self.re_PlayerInfo) + log.debug(_("readplayerstacks: re is '%s'" % self.re_PlayerInfo)) m = self.re_PlayerInfo.finditer(hand.handText) for a in m: hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH')) @@ -230,7 +230,7 @@ class Winamax(HandHistoryConverter): # print "adding street", m.group(0) # print "---" except: - print ("Failed to add streets. handtext=%s") + print (_("Failed to add streets. handtext=%s")) #Needs to return a list in the format # ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb, @@ -240,7 +240,7 @@ class Winamax(HandHistoryConverter): m = self.re_Button.search(hand.handText) if m: hand.buttonpos = int(m.group('BUTTON')) - log.debug('readButton: button on pos %d'%hand.buttonpos) + log.debug(_('readButton: button on pos %d'%hand.buttonpos)) else: log.warning(_('readButton: not found')) @@ -292,13 +292,13 @@ class Winamax(HandHistoryConverter): if street in hand.streets.keys(): m = self.re_HeroCards.finditer(hand.streets[street]) if m == []: - log.debug("No hole cards found for %s"%street) + log.debug(_("No hole cards found for %s"%street)) for found in m: hand.hero = found.group('PNAME') newcards = found.group('CARDS').split(' ') # print "DEBUG: addHoleCards(%s, %s, %s)" %(street, hand.hero, newcards) hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True) - log.debug("Hero cards %s: %s"%(hand.hero, newcards)) + log.debug(_("Hero cards %s: %s"%(hand.hero, newcards))) def readAction(self, hand, street): m = self.re_Action.finditer(hand.streets[street]) @@ -319,13 +319,13 @@ class Winamax(HandHistoryConverter): elif action.group('ATYPE') == ' stands pat': hand.addStandsPat( street, action.group('PNAME')) else: - log.fatal("DEBUG: unimplemented readAction: '%s' '%s'") %(action.group('PNAME'),action.group('ATYPE'),) + log.fatal(_("DEBUG: unimplemented readAction: '%s' '%s'")) %(action.group('PNAME'),action.group('ATYPE'),) # print "Processed %s"%acts # print "committed=",hand.pot.committed def readShowdownActions(self, hand): for shows in self.re_ShowdownAction.finditer(hand.handText): - log.debug("add show actions %s"%shows) + log.debug(_("add show actions %s"%shows)) cards = shows.group('CARDS') cards = cards.split(' ') # print "DEBUG: addShownCards(%s, %s)" %(cards, shows.group('PNAME')) @@ -371,7 +371,7 @@ class Winamax(HandHistoryConverter): def readShownCards(self,hand): for m in self.re_ShownCards.finditer(hand.handText): - log.debug("Read shown cards: %s"%m.group(0)) + log.debug(_("Read shown cards: %s"%m.group(0))) cards = m.group('CARDS') cards = cards.split(' ') # needs to be a list, not a set--stud needs the order (shown, mucked) = (False, False)