gettext-ify tournesummary and interlocks

This commit is contained in:
steffen123 2010-08-16 01:58:05 +02:00
parent 2a69e927d2
commit cff0206e4d
2 changed files with 68 additions and 55 deletions

View File

@ -30,6 +30,19 @@ import operator
import time,datetime import time,datetime
from copy import deepcopy from copy import deepcopy
from Exceptions import * from Exceptions import *
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
import pprint import pprint
import DerivedStats import DerivedStats
import Card import Card
@ -118,59 +131,59 @@ class TourneySummary(object):
def __str__(self): def __str__(self):
#TODO : Update #TODO : Update
vars = ( ("SITE", self.siteName), vars = ( (_("SITE"), self.siteName),
("START TIME", self.startTime), (_("START TIME"), self.startTime),
("END TIME", self.endTime), (_("END TIME"), self.endTime),
("TOURNEY NAME", self.tourneyName), (_("TOURNEY NAME"), self.tourneyName),
("TOURNEY NO", self.tourNo), (_("TOURNEY NO"), self.tourNo),
("TOURNEY TYPE ID", self.tourneyTypeId), (_("TOURNEY TYPE ID"), self.tourneyTypeId),
("TOURNEY ID", self.tourneyId), (_("TOURNEY ID"), self.tourneyId),
("BUYIN", self.buyin), (_("BUYIN"), self.buyin),
("FEE", self.fee), (_("FEE"), self.fee),
("CURRENCY", self.currency), (_("CURRENCY"), self.currency),
("HERO", self.hero), (_("HERO"), self.hero),
("MAXSEATS", self.maxseats), (_("MAXSEATS"), self.maxseats),
("ENTRIES", self.entries), (_("ENTRIES"), self.entries),
("SPEED", self.speed), (_("SPEED"), self.speed),
("PRIZE POOL", self.prizepool), (_("PRIZE POOL"), self.prizepool),
("STARTING CHIP COUNT", self.buyInChips), (_("STARTING CHIP COUNT"), self.buyInChips),
("MIXED", self.mixed), (_("MIXED"), self.mixed),
("REBUY", self.isRebuy), (_("REBUY"), self.isRebuy),
("ADDON", self.isAddOn), (_("ADDON"), self.isAddOn),
("KO", self.isKO), (_("KO"), self.isKO),
("MATRIX", self.isMatrix), (_("MATRIX"), self.isMatrix),
("MATRIX ID PROCESSED", self.matrixIdProcessed), (_("MATRIX ID PROCESSED"), self.matrixIdProcessed),
("SHOOTOUT", self.isShootout), (_("SHOOTOUT"), self.isShootout),
("MATRIX MATCH ID", self.matrixMatchId), (_("MATRIX MATCH ID"), self.matrixMatchId),
("SUB TOURNEY BUY IN", self.subTourneyBuyin), (_("SUB TOURNEY BUY IN"), self.subTourneyBuyin),
("SUB TOURNEY FEE", self.subTourneyFee), (_("SUB TOURNEY FEE"), self.subTourneyFee),
("REBUY CHIPS", self.rebuyChips), (_("REBUY CHIPS"), self.rebuyChips),
("ADDON CHIPS", self.addOnChips), (_("ADDON CHIPS"), self.addOnChips),
("REBUY COST", self.rebuyCost), (_("REBUY COST"), self.rebuyCost),
("ADDON COST", self.addOnCost), (_("ADDON COST"), self.addOnCost),
("TOTAL REBUYS", self.totalRebuyCount), (_("TOTAL REBUYS"), self.totalRebuyCount),
("TOTAL ADDONS", self.totalAddOnCount), (_("TOTAL ADDONS"), self.totalAddOnCount),
("KO BOUNTY", self.koBounty), (_("KO BOUNTY"), self.koBounty),
("TOURNEY COMMENT", self.tourneyComment), (_("TOURNEY COMMENT"), self.tourneyComment),
("SNG", self.isSng), (_("SNG"), self.isSng),
("SATELLITE", self.isSatellite), (_("SATELLITE"), self.isSatellite),
("DOUBLE OR NOTHING", self.isDoubleOrNothing), (_("DOUBLE OR NOTHING"), self.isDoubleOrNothing),
("GUARANTEE", self.guarantee), (_("GUARANTEE"), self.guarantee),
("ADDED", self.added), (_("ADDED"), self.added),
("ADDED CURRENCY", self.addedCurrency), (_("ADDED CURRENCY"), self.addedCurrency),
("COMMENT", self.comment), (_("COMMENT"), self.comment),
("COMMENT TIMESTAMP", self.commentTs) (_("COMMENT TIMESTAMP"), self.commentTs)
) )
structs = ( ("PLAYER IDS", self.playerIds), structs = ( (_("PLAYER IDS"), self.playerIds),
("PLAYERS", self.players), (_("PLAYERS"), self.players),
("TOURNEYS PLAYERS IDS", self.tourneysPlayersIds), (_("TOURNEYS PLAYERS IDS"), self.tourneysPlayersIds),
("RANKS", self.ranks), (_("RANKS"), self.ranks),
("WINNINGS", self.winnings), (_("WINNINGS"), self.winnings),
("WINNINGS CURRENCY", self.winningsCurrency), (_("WINNINGS CURRENCY"), self.winningsCurrency),
("COUNT REBUYS", self.rebuyCounts), (_("COUNT REBUYS"), self.rebuyCounts),
("COUNT ADDONS", self.addOnCounts), (_("COUNT ADDONS"), self.addOnCounts),
("NB OF KO", self.koCounts) (_("NB OF KO"), self.koCounts)
) )
str = '' str = ''
for (name, var) in vars: for (name, var) in vars:
@ -217,7 +230,7 @@ class TourneySummary(object):
self.tourneysPlayersIds = self.db.createOrUpdateTourneysPlayers(self, "TS") self.tourneysPlayersIds = self.db.createOrUpdateTourneysPlayers(self, "TS")
self.db.commit() self.db.commit()
logging.debug("Tourney Insert/Update done") logging.debug(_("Tourney Insert/Update done"))
# TO DO : Return what has been done (tourney created, updated, nothing) # TO DO : Return what has been done (tourney created, updated, nothing)
# ?? stored = 1 if tourney is fully created / duplicates = 1, if everything was already here and correct / partial=1 if some things were already here (between tourney, tourneysPlayers and handsPlayers) # ?? stored = 1 if tourney is fully created / duplicates = 1, if everything was already here and correct / partial=1 if some things were already here (between tourney, tourneysPlayers and handsPlayers)
@ -237,7 +250,7 @@ rank (int) indicating the finishing rank (can be -1 if unknown)
name (string) player name name (string) player name
winnings (decimal) the money the player ended the tourney with (can be 0, or -1 if unknown) winnings (decimal) the money the player ended the tourney with (can be 0, or -1 if unknown)
""" """
log.debug("addPlayer: rank:%s - name : '%s' - Winnings (%s)" % (rank, name, winnings)) log.debug(_("addPlayer: rank:%s - name : '%s' - Winnings (%s)") % (rank, name, winnings))
self.players.append(name) self.players.append(name)
if rank: if rank:
self.ranks.update( { name : Decimal(rank) } ) self.ranks.update( { name : Decimal(rank) } )
@ -264,7 +277,7 @@ winnings (decimal) the money the player ended the tourney with (can be 0, or
#end def addPlayer #end def addPlayer
def incrementPlayerWinnings(self, name, additionnalWinnings): def incrementPlayerWinnings(self, name, additionnalWinnings):
log.debug("incrementPlayerWinnings: name : '%s' - Add Winnings (%s)" % (name, additionnalWinnings)) log.debug(_("incrementPlayerWinnings: name : '%s' - Add Winnings (%s)") % (name, additionnalWinnings))
oldWins = 0 oldWins = 0
if self.winnings.has_key(name): if self.winnings.has_key(name):
oldWins = self.winnings[name] oldWins = self.winnings[name]

View File

@ -46,7 +46,7 @@ class InterProcessLockBase:
if source == None: if source == None:
source="Unknown" source="Unknown"
if self._has_lock: # make sure 2nd acquire in same process fails if self._has_lock: # make sure 2nd acquire in same process fails
print "lock already held by:",self.heldBy print _("lock already held by:"),self.heldBy
return False return False
while not self._has_lock: while not self._has_lock:
try: try: