gettextify hand

This commit is contained in:
steffen123 2010-08-15 05:59:05 +02:00
parent fd03cb6560
commit 7dafc12206

View File

@ -135,59 +135,59 @@ class Hand(object):
self.is_duplicate = False # i.e. don't update hudcache if true self.is_duplicate = False # i.e. don't update hudcache if true
def __str__(self): def __str__(self):
vars = ( ("BB", self.bb), vars = ( (_("BB"), self.bb),
("SB", self.sb), (_("SB"), self.sb),
("BUTTONPOS", self.buttonpos), (_("BUTTONPOS"), self.buttonpos),
("HAND NO.", self.handid), (_("HAND NO."), self.handid),
("SITE", self.sitename), (_("SITE"), self.sitename),
("TABLE NAME", self.tablename), (_("TABLE NAME"), self.tablename),
("HERO", self.hero), (_("HERO"), self.hero),
("MAXSEATS", self.maxseats), (_("MAXSEATS"), self.maxseats),
("LEVEL", self.level), (_("LEVEL"), self.level),
("MIXED", self.mixed), (_("MIXED"), self.mixed),
("LASTBET", self.lastBet), (_("LASTBET"), self.lastBet),
("ACTION STREETS", self.actionStreets), (_("ACTION STREETS"), self.actionStreets),
("STREETS", self.streets), (_("STREETS"), self.streets),
("ALL STREETS", self.allStreets), (_("ALL STREETS"), self.allStreets),
("COMMUNITY STREETS", self.communityStreets), (_("COMMUNITY STREETS"), self.communityStreets),
("HOLE STREETS", self.holeStreets), (_("HOLE STREETS"), self.holeStreets),
("COUNTED SEATS", self.counted_seats), (_("COUNTED SEATS"), self.counted_seats),
("DEALT", self.dealt), (_("DEALT"), self.dealt),
("SHOWN", self.shown), (_("SHOWN"), self.shown),
("MUCKED", self.mucked), (_("MUCKED"), self.mucked),
("TOTAL POT", self.totalpot), (_("TOTAL POT"), self.totalpot),
("TOTAL COLLECTED", self.totalcollected), (_("TOTAL COLLECTED"), self.totalcollected),
("RAKE", self.rake), (_("RAKE"), self.rake),
("START TIME", self.startTime), (_("START TIME"), self.startTime),
("TOURNAMENT NO", self.tourNo), (_("TOURNAMENT NO"), self.tourNo),
("TOURNEY ID", self.tourneyId), (_("TOURNEY ID"), self.tourneyId),
("TOURNEY TYPE ID", self.tourneyTypeId), (_("TOURNEY TYPE ID"), self.tourneyTypeId),
("BUYIN", self.buyin), (_("BUYIN"), self.buyin),
("BUYIN CURRENCY", self.buyinCurrency), (_("BUYIN CURRENCY"), self.buyinCurrency),
("BUYIN CHIPS", self.buyInChips), (_("BUYIN CHIPS"), self.buyInChips),
("FEE", self.fee), (_("FEE"), self.fee),
("IS REBUY", self.isRebuy), (_("IS REBUY"), self.isRebuy),
("IS ADDON", self.isAddOn), (_("IS ADDON"), self.isAddOn),
("IS KO", self.isKO), (_("IS KO"), self.isKO),
("KO BOUNTY", self.koBounty), (_("KO BOUNTY"), self.koBounty),
("IS MATRIX", self.isMatrix), (_("IS MATRIX"), self.isMatrix),
("IS SHOOTOUT", self.isShootout), (_("IS SHOOTOUT"), self.isShootout),
("TOURNEY COMMENT", self.tourneyComment), (_("TOURNEY COMMENT"), self.tourneyComment),
) )
structs = ( ("PLAYERS", self.players), structs = ( (_("PLAYERS"), self.players),
("STACKS", self.stacks), (_("STACKS"), self.stacks),
("POSTED", self.posted), (_("POSTED"), self.posted),
("POT", self.pot), (_("POT"), self.pot),
("SEATING", self.seating), (_("SEATING"), self.seating),
("GAMETYPE", self.gametype), (_("GAMETYPE"), self.gametype),
("ACTION", self.actions), (_("ACTION"), self.actions),
("COLLECTEES", self.collectees), (_("COLLECTEES"), self.collectees),
("BETS", self.bets), (_("BETS"), self.bets),
("BOARD", self.board), (_("BOARD"), self.board),
("DISCARDS", self.discards), (_("DISCARDS"), self.discards),
("HOLECARDS", self.holecards), (_("HOLECARDS"), self.holecards),
("TOURNEYS PLAYER IDS", self.tourneysPlayersIds), (_("TOURNEYS PLAYER IDS"), self.tourneysPlayersIds),
) )
str = '' str = ''
for (name, var) in vars: for (name, var) in vars:
@ -210,7 +210,7 @@ dealt whether they were seen in a 'dealt to' line
try: try:
self.checkPlayerExists(player) self.checkPlayerExists(player)
except FpdbParseError, e: except FpdbParseError, e:
print "[ERROR] Tried to add holecards for unknown player: %s" % (player,) print _("[ERROR] Tried to add holecards for unknown player: %s") % (player,)
return return
if dealt: self.dealt.add(player) if dealt: self.dealt.add(player)
@ -263,7 +263,7 @@ db: a connected Database object"""
# TODO HandsActions - all actions for all players for all streets - self.actions # TODO HandsActions - all actions for all players for all streets - self.actions
# HudCache data can be generated from HandsActions (HandsPlayers?) # HudCache data can be generated from HandsActions (HandsPlayers?)
else: else:
log.info("Hand.insert(): hid #: %s is a duplicate" % hh['siteHandNo']) log.info(_("Hand.insert(): hid #: %s is a duplicate") % hh['siteHandNo'])
self.is_duplicate = True # i.e. don't update hudcache self.is_duplicate = True # i.e. don't update hudcache
raise FpdbHandDuplicate(hh['siteHandNo']) raise FpdbHandDuplicate(hh['siteHandNo'])
@ -302,15 +302,14 @@ If a player has None chips he won't be added."""
log.debug("markStreets:\n"+ str(self.streets)) log.debug("markStreets:\n"+ str(self.streets))
else: else:
tmp = self.handText[0:100] tmp = self.handText[0:100]
log.error("markstreets didn't match") log.error(_("markstreets didn't match - Assuming hand cancelled"))
log.error(" - Assuming hand cancelled")
self.cancelled = True self.cancelled = True
raise FpdbParseError("FpdbParseError: markStreets appeared to fail: First 100 chars: '%s'" % tmp) raise FpdbParseError(_("FpdbParseError: markStreets appeared to fail: First 100 chars: '%s'") % tmp)
def checkPlayerExists(self,player): def checkPlayerExists(self,player):
if player not in [p[1] for p in self.players]: if player not in [p[1] for p in self.players]:
print "DEBUG: checkPlayerExists %s fail" % player print _("DEBUG: checkPlayerExists %s fail") % player
raise FpdbParseError("checkPlayerExists: '%s' failed." % player) raise FpdbParseError(_("checkPlayerExists: '%s' failed.") % player)
@ -393,7 +392,7 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio
def addCall(self, street, player=None, amount=None): def addCall(self, street, player=None, amount=None):
if amount: if amount:
amount = re.sub(u',', u'', amount) #some sites have commas amount = re.sub(u',', u'', amount) #some sites have commas
log.debug("%s %s calls %s" %(street, player, amount)) log.debug(_("%s %s calls %s") %(street, player, amount))
# Potentially calculate the amount of the call if not supplied # Potentially calculate the amount of the call if not supplied
# corner cases include if player would be all in # corner cases include if player would be all in
if amount is not None: if amount is not None:
@ -463,7 +462,7 @@ Add a raise on [street] by [player] to [amountTo]
self._addRaise(street, player, C, Rb, Rt) self._addRaise(street, player, C, Rb, Rt)
def _addRaise(self, street, player, C, Rb, Rt): def _addRaise(self, street, player, C, Rb, Rt):
log.debug("%s %s raise %s" %(street, player, Rt)) log.debug(_("%s %s raise %s") %(street, player, Rt))
self.bets[street][player].append(C + Rb) self.bets[street][player].append(C + Rb)
self.stacks[player] -= (C + Rb) self.stacks[player] -= (C + Rb)
act = (player, 'raises', Rb, Rt, C, self.stacks[player]==0) act = (player, 'raises', Rb, Rt, C, self.stacks[player]==0)
@ -474,7 +473,7 @@ Add a raise on [street] by [player] to [amountTo]
def addBet(self, street, player, amount): def addBet(self, street, player, amount):
log.debug("%s %s bets %s" %(street, player, amount)) log.debug(_("%s %s bets %s") %(street, player, amount))
amount = re.sub(u',', u'', amount) #some sites have commas amount = re.sub(u',', u'', amount) #some sites have commas
self.checkPlayerExists(player) self.checkPlayerExists(player)
self.bets[street][player].append(Decimal(amount)) self.bets[street][player].append(Decimal(amount))
@ -493,7 +492,7 @@ Add a raise on [street] by [player] to [amountTo]
def addFold(self, street, player): def addFold(self, street, player):
log.debug("%s %s folds" % (street, player)) log.debug(_("%s %s folds") % (street, player))
self.checkPlayerExists(player) self.checkPlayerExists(player)
self.folded.add(player) self.folded.add(player)
self.pot.addFold(player) self.pot.addFold(player)
@ -502,7 +501,7 @@ Add a raise on [street] by [player] to [amountTo]
def addCheck(self, street, player): def addCheck(self, street, player):
#print "DEBUG: %s %s checked" % (street, player) #print "DEBUG: %s %s checked" % (street, player)
logging.debug("%s %s checks" % (street, player)) logging.debug(_("%s %s checks") % (street, player))
self.checkPlayerExists(player) self.checkPlayerExists(player)
self.actions[street].append((player, 'checks')) self.actions[street].append((player, 'checks'))
@ -522,7 +521,7 @@ Add a raise on [street] by [player] to [amountTo]
For when a player shows cards for any reason (for showdown or out of choice). For when a player shows cards for any reason (for showdown or out of choice).
Card ranks will be uppercased Card ranks will be uppercased
""" """
log.debug("addShownCards %s hole=%s all=%s" % (player, cards, holeandboard)) log.debug(_("addShownCards %s hole=%s all=%s") % (player, cards, holeandboard))
if cards is not None: if cards is not None:
self.addHoleCards(cards,player,shown, mucked) self.addHoleCards(cards,player,shown, mucked)
elif holeandboard is not None: elif holeandboard is not None:
@ -633,9 +632,9 @@ Map the tuple self.gametype onto the pokerstars string describing it
try: try:
timestr = datetime.datetime.strftime(self.startTime, '%Y/%m/%d %H:%M:%S ET') timestr = datetime.datetime.strftime(self.startTime, '%Y/%m/%d %H:%M:%S ET')
except TypeError: except TypeError:
print "*** ERROR - HAND: calling writeGameLine with unexpected STARTTIME value, expecting datetime.date object, received:", self.startTime print _("*** ERROR - HAND: calling writeGameLine with unexpected STARTTIME value, expecting datetime.date object, received:"), self.startTime
print "*** Make sure your HandHistoryConverter is setting hand.startTime properly!" print _("*** Make sure your HandHistoryConverter is setting hand.startTime properly!")
print "*** Game String:", gs print _("*** Game String:"), gs
return gs return gs
else: else:
return gs + timestr return gs + timestr
@ -689,7 +688,7 @@ class HoldemOmahaHand(Hand):
try: hhc.readBlinds(self) try: hhc.readBlinds(self)
except: except:
print "*** Parse error reading blinds (check compilePlayerRegexs as a likely culprit)", self print _("*** Parse error reading blinds (check compilePlayerRegexs as a likely culprit)"), self
return return
hhc.readAntes(self) hhc.readAntes(self)
@ -716,9 +715,9 @@ class HoldemOmahaHand(Hand):
if handid is not None: if handid is not None:
self.select(handid) # Will need a handId self.select(handid) # Will need a handId
else: else:
log.warning("HoldemOmahaHand.__init__:Can't assemble hand from db without a handid") log.warning(_("HoldemOmahaHand.__init__:Can't assemble hand from db without a handid"))
else: else:
log.warning("HoldemOmahaHand.__init__:Neither HHC nor DB+handid provided") log.warning(_("HoldemOmahaHand.__init__:Neither HHC nor DB+handid provided"))
pass pass
@ -1230,7 +1229,7 @@ closed likewise, but known only to player
self.checkPlayerExists(player) self.checkPlayerExists(player)
self.holecards[street][player] = (open, closed) self.holecards[street][player] = (open, closed)
except FpdbParseError, e: except FpdbParseError, e:
print "[ERROR] Tried to add holecards for unknown player: %s" % (player,) print _("[ERROR] Tried to add holecards for unknown player: %s") % (player,)
# TODO: def addComplete(self, player, amount): # TODO: def addComplete(self, player, amount):
def addComplete(self, street, player, amountTo): def addComplete(self, street, player, amountTo):
@ -1239,7 +1238,7 @@ closed likewise, but known only to player
"""\ """\
Add a complete on [street] by [player] to [amountTo] Add a complete on [street] by [player] to [amountTo]
""" """
log.debug("%s %s completes %s" % (street, player, amountTo)) log.debug(_("%s %s completes %s") % (street, player, amountTo))
amountTo = re.sub(u',', u'', amountTo) #some sites have commas amountTo = re.sub(u',', u'', amountTo) #some sites have commas
self.checkPlayerExists(player) self.checkPlayerExists(player)
Bp = self.lastBet['THIRD'] Bp = self.lastBet['THIRD']
@ -1257,7 +1256,7 @@ Add a complete on [street] by [player] to [amountTo]
def addBringIn(self, player, bringin): def addBringIn(self, player, bringin):
if player is not None: if player is not None:
log.debug("Bringin: %s, %s" % (player , bringin)) log.debug(_("Bringin: %s, %s") % (player , bringin))
self.bets['THIRD'][player].append(Decimal(bringin)) self.bets['THIRD'][player].append(Decimal(bringin))
self.stacks[player] -= Decimal(bringin) self.stacks[player] -= Decimal(bringin)
act = (player, 'bringin', bringin, self.stacks[player]==0) act = (player, 'bringin', bringin, self.stacks[player]==0)
@ -1437,8 +1436,8 @@ Add a complete on [street] by [player] to [amountTo]
#Non hero folded before showdown, add first two downcards #Non hero folded before showdown, add first two downcards
holecards = [u'0x', u'0x'] + holecards holecards = [u'0x', u'0x'] + holecards
else: else:
log.warning("join_holecards: # of holecards should be either < 4, 4 or 7 - 5 and 6 should be impossible for anyone who is not a hero") log.warning(_("join_holecards: # of holecards should be either < 4, 4 or 7 - 5 and 6 should be impossible for anyone who is not a hero"))
log.warning("join_holcards: holecards(%s): %s" %(player, holecards)) log.warning(_("join_holcards: holecards(%s): %s") %(player, holecards))
return holecards return holecards
@ -1521,9 +1520,9 @@ class Pot(object):
if self.sym is None: if self.sym is None:
self.sym = "C" self.sym = "C"
if self.total is None: if self.total is None:
print "DEBUG: call Pot.end() before printing pot total" print _("DEBUG: call Pot.end() before printing pot total")
# NB if I'm sure end() is idempotent, call it here. # NB if I'm sure end() is idempotent, call it here.
raise FpdbParseError("FpdbError in printing Hand object") raise FpdbParseError(_("FpdbError in printing Hand object"))
ret = "Total pot %s%.2f" % (self.sym, self.total) ret = "Total pot %s%.2f" % (self.sym, self.total)
if len(self.pots) < 2: if len(self.pots) < 2: