missed file for last commit

This commit is contained in:
steffen123 2010-07-08 20:00:43 +02:00
parent c6b6f8a788
commit 10cfaf2c75

View File

@ -1,4 +1,4 @@
#!/usr/bin/python2 #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#Copyright 2009-2010 Stephane Alessio #Copyright 2009-2010 Stephane Alessio
@ -47,10 +47,11 @@ class TourneySummary(object):
SITEIDS = {'Fulltilt':1, 'PokerStars':2, 'Everleaf':3, 'Win2day':4, 'OnGame':5, 'UltimateBet':6, 'Betfair':7, 'Absolute':8, 'PartyPoker':9 } SITEIDS = {'Fulltilt':1, 'PokerStars':2, 'Everleaf':3, 'Win2day':4, 'OnGame':5, 'UltimateBet':6, 'Betfair':7, 'Absolute':8, 'PartyPoker':9 }
def __init__(self, sitename, gametype, summaryText, builtFrom = "HHC"): def __init__(self, db, config, siteName, summaryText, builtFrom = "HHC"):
self.sitename = sitename self.db = db
self.siteId = self.SITEIDS[sitename] self.config = config
self.gametype = gametype self.siteName = siteName
self.siteId = self.SITEIDS[siteName]
self.summaryText = summaryText self.summaryText = summaryText
self.tourneyName = None self.tourneyName = None
@ -92,6 +93,8 @@ class TourneySummary(object):
self.guarantee = 0 self.guarantee = 0
# Collections indexed by player names # Collections indexed by player names
self.playerIds = {}
self.tourneysPlayersIds = {}
self.ranks = {} self.ranks = {}
self.winnings = {} self.winnings = {}
self.winningsCurrency = {} self.winningsCurrency = {}
@ -101,16 +104,15 @@ class TourneySummary(object):
# currency symbol for this summary # currency symbol for this summary
self.sym = None self.sym = None
#self.sym = self.SYMBOL[self.gametype['currency']] # save typing! delete this attr when done
if builtFrom=="IMAP": if builtFrom=="IMAP":
self.parseSummary() self.parseSummary()
#TODO: self.insert() self.insertOrUpdate()
#end def __init__ #end def __init__
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),
@ -119,6 +121,7 @@ class TourneySummary(object):
("TOURNEY ID", self.tourneyId), ("TOURNEY ID", self.tourneyId),
("BUYIN", self.buyin), ("BUYIN", self.buyin),
("FEE", self.fee), ("FEE", self.fee),
("CURRENCY", self.currency),
("HERO", self.hero), ("HERO", self.hero),
("MAXSEATS", self.maxseats), ("MAXSEATS", self.maxseats),
("ENTRIES", self.entries), ("ENTRIES", self.entries),
@ -148,8 +151,9 @@ class TourneySummary(object):
("GUARANTEE", self.guarantee) ("GUARANTEE", self.guarantee)
) )
structs = ( ("GAMETYPE", self.gametype), structs = ( ("PLAYER IDS", self.playerIds),
("PLAYERS", self.players), ("PLAYERS", self.players),
("TOURNEYS PLAYERS IDS", self.tourneysPlayersIds),
("RANKS", self.ranks), ("RANKS", self.ranks),
("WINNINGS", self.winnings), ("WINNINGS", self.winnings),
("COUNT REBUYS", self.rebuyCounts), ("COUNT REBUYS", self.rebuyCounts),
@ -171,9 +175,7 @@ class TourneySummary(object):
def getSummaryText(self): def getSummaryText(self):
return self.summaryText return self.summaryText
def insert(self, db): def insertOrUpdate(self):
# Note that this method is not used by the PS tourney storage stuff - this is for summary files only
# First : check all needed info is filled in the object, especially for the initial select # First : check all needed info is filled in the object, especially for the initial select
# Notes on DB Insert # Notes on DB Insert
@ -184,15 +186,28 @@ class TourneySummary(object):
# Starttime may not match the one in the Summary file : HH = time of the first Hand / could be slighltly different from the one in the summary file # Starttime may not match the one in the Summary file : HH = time of the first Hand / could be slighltly different from the one in the summary file
# Note: If the TourneyNo could be a unique id .... this would really be a relief to deal with matrix matches ==> Ask on the IRC / Ask Fulltilt ?? # Note: If the TourneyNo could be a unique id .... this would really be a relief to deal with matrix matches ==> Ask on the IRC / Ask Fulltilt ??
dbTourneyTypeId = db.getTourneyTypeId(self) for player in self.players:
logging.debug("Tourney Type ID = %d" % dbTourneyTypeId) id=self.db.get_player_id(self.config, self.siteName, player)
dbTourneyId = db.tRecognizeTourney(self, dbTourneyTypeId) if not id:
logging.debug("Tourney ID = %d" % dbTourneyId) self.db.insertPlayer(player, self.siteId)
dbTourneysPlayersIds = db.tStoreTourneysPlayers(self, dbTourneyId) id=self.db.get_last_insert_id(self.db.cursor)
logging.debug("TourneysPlayersId = %s" % dbTourneysPlayersIds)
db.tUpdateTourneysHandsPlayers(self, dbTourneysPlayersIds, dbTourneyTypeId) self.playerIds.update({player:id})
logging.debug("tUpdateTourneysHandsPlayers done")
logging.debug("Tourney Insert done") print "TS.insert players",self.players,"playerIds",self.playerIds
self.buyinCurrency=self.currency
self.dbid_pids=self.playerIds #TODO:rename this field in Hand so this silly renaming can be removed
#print "TS.self before starting insert",self
self.tourneyTypeId = self.db.createOrUpdateTourneyType(self)
self.db.commit()
self.tourneyId = self.db.createOrUpdateTourney(self)
self.db.commit()
self.tourneysPlayersIds = self.db.createOrUpdateTourneysPlayers(self, "TourneySummary")
self.db.commit()
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)
@ -240,35 +255,6 @@ winnings (decimal) the money the player ended the tourney with (can be 0, or
print "checkPlayerExists", player, "fail" print "checkPlayerExists", player, "fail"
raise FpdbParseError raise FpdbParseError
def getGameTypeAsString(self):
"""\
Map the tuple self.gametype onto the pokerstars string describing it
"""
# currently it appears to be something like ["ring", "hold", "nl", sb, bb]:
gs = {"holdem" : "Hold'em",
"omahahi" : "Omaha",
"omahahilo" : "Omaha Hi/Lo",
"razz" : "Razz",
"studhi" : "7 Card Stud",
"studhilo" : "7 Card Stud Hi/Lo",
"fivedraw" : "5 Card Draw",
"27_1draw" : "FIXME",
"27_3draw" : "Triple Draw 2-7 Lowball",
"badugi" : "Badugi"
}
ls = {"nl" : "No Limit",
"pl" : "Pot Limit",
"fl" : "Limit",
"cn" : "Cap No Limit",
"cp" : "Cap Pot Limit"
}
log.debug("gametype: %s" %(self.gametype))
retstring = "%s %s" %(gs[self.gametype['category']], ls[self.gametype['limitType']])
return retstring
def writeSummary(self, fh=sys.__stdout__): def writeSummary(self, fh=sys.__stdout__):
print >>fh, "Override me" print >>fh, "Override me"
@ -280,7 +266,7 @@ def assemble(cnxn, tourneyId): #TODO: move this method to Hand or Database
# TODO !! # TODO !!
c = cnxn.cursor() c = cnxn.cursor()
# We need at least sitename, gametype, handid # We need at least siteName, gametype, handid
# for the Hand.__init__ # for the Hand.__init__
c.execute(""" c.execute("""
select select
@ -316,7 +302,7 @@ limit 1""", {'handid':handid})
#TODO: siteid should be in hands table - we took the scenic route through players here. #TODO: siteid should be in hands table - we took the scenic route through players here.
res = c.fetchone() 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]} 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]}
h = HoldemOmahaHand(hhc = None, sitename=res[0], gametype = gametype, handText=None, builtFrom = "DB", handid=handid) h = HoldemOmahaHand(hhc = None, siteName=res[0], gametype = gametype, handText=None, builtFrom = "DB", handid=handid)
cards = map(Card.valueSuitFromCard, res[11:16] ) cards = map(Card.valueSuitFromCard, res[11:16] )
if cards[0]: if cards[0]:
h.setCommunityCards('FLOP', cards[0:3]) h.setCommunityCards('FLOP', cards[0:3])