Some fixes in FTP summary parsing and preparations for summary import in DB. No behaviour change expected
modified: FulltiltToFpdb.py * Tourney Summary File parsing : add support for Madness tourneys * HH file parsing : enhance Tourney topline parsing to retrieve some info (HU, Rebuy, KO, Turbo, ...) and store it into Hand object modified: Hand.py * Some attributes added to store tourney specific info modified: SQL.py * Add a new request (getTourneyTypeIdByTourneyNo) to help finding a tourney already in db (preparation for Tourney Summary import) modified: Tourney.py * Attribute tourneyComment added modified: fpdb_parse_logic.py * Change parameters in call of fpdb_simple.recogniseTourneyTypeId modified: fpdb_simple.py * recogniseTourneyTypeId : signature changed to allow for the search of a tourney id already in db prior to searching for tourneyTypeId
This commit is contained in:
parent
cb8bc13ceb
commit
b85f8ec155
|
@ -57,6 +57,13 @@ class Fulltilt(HandHistoryConverter):
|
|||
(?P<PARTIAL>\(partial\))?\n
|
||||
(?:.*?\n(?P<CANCELLED>Hand\s\#(?P=HID)\shas\sbeen\scanceled))?
|
||||
''', re.VERBOSE|re.DOTALL)
|
||||
re_TourneyExtraInfo = re.compile('''(((?P<TOURNEY_NAME>[^$]+)?
|
||||
(?P<CURRENCY>\$)?(?P<BUYIN>[.0-9]+)?\s*\+\s*\$?(?P<FEE>[.0-9]+)?
|
||||
(\s(?P<SPECIAL>(KO|Heads\sUp|Matrix\s\dx|Rebuy|Madness)))?
|
||||
(\s(?P<SHOOTOUT>Shootout))?
|
||||
(\s(?P<SNG>Sit\s&\sGo))?
|
||||
(\s\((?P<TURBO>Turbo)\))?)|(?P<UNREADABLE_INFO>.+))
|
||||
''', re.VERBOSE)
|
||||
re_Button = re.compile('^The button is in seat #(?P<BUTTON>\d+)', re.MULTILINE)
|
||||
re_PlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$(?P<CASH>[,.0-9]+)\)$', re.MULTILINE)
|
||||
re_TourneyPlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$?(?P<CASH>[,.0-9]+)\)', re.MULTILINE)
|
||||
|
@ -66,7 +73,7 @@ class Fulltilt(HandHistoryConverter):
|
|||
re_TourneyInfo = re.compile('''Tournament\sSummary\s
|
||||
(?P<TOURNAMENT_NAME>[^$(]+)?\s*
|
||||
((?P<CURRENCY>\$|)?(?P<BUYIN>[.0-9]+)\s*\+\s*\$?(?P<FEE>[.0-9]+)\s)?
|
||||
((?P<SPECIAL>(KO|Heads\sUp|Matrix\s\dx|Rebuy))\s)?
|
||||
((?P<SPECIAL>(KO|Heads\sUp|Matrix\s\dx|Rebuy|Madness))\s)?
|
||||
((?P<SHOOTOUT>Shootout)\s)?
|
||||
((?P<SNG>Sit\s&\sGo)\s)?
|
||||
(\((?P<TURBO1>Turbo)\)\s)?
|
||||
|
@ -202,16 +209,30 @@ class Fulltilt(HandHistoryConverter):
|
|||
if m.group('PLAY') != None:
|
||||
hand.gametype['currency'] = 'play'
|
||||
|
||||
# TODO: if there's a way to figure these out, we should.. otherwise we have to stuff it with unknowns
|
||||
re_SNGBuyInFee = re.compile('''(?P<CURRENCY>\$)?(?P<BUYIN>[.0-9]+) \+ \$?(?P<FEE>[.0-9]+) (?P<EXTRA_INFO>[\sA-Za-z&()]+)?''')
|
||||
# TO DO : See if important info can be retrieved from EXTRA_INFO (sould be things like Turbo, Matrix, KO, ...)
|
||||
try:
|
||||
n = re_SNGBuyInFee.search(m.group('TOURNAMENT'))
|
||||
#print "cur %s BUYIN %s FEE %s EXTRA %s" %(n.group('CURRENCY'), n.group('BUYIN'), n.group('FEE'), n.group('EXTRA_INFO'))
|
||||
# Done: if there's a way to figure these out, we should.. otherwise we have to stuff it with unknowns
|
||||
if m.group('TOURNAMENT') is not None:
|
||||
n = self.re_TourneyExtraInfo.search(m.group('TOURNAMENT'))
|
||||
if n.group('UNREADABLE_INFO') is not None:
|
||||
hand.tourneyComment = n.group('UNREADABLE_INFO')
|
||||
else:
|
||||
hand.tourneyComment = n.group('TOURNEY_NAME') # can be None
|
||||
if (n.group('CURRENCY') is not None and n.group('BUYIN') is not None and n.group('FEE') is not None):
|
||||
hand.buyin = "%s%s+%s%s" %(n.group('CURRENCY'), n.group('BUYIN'), n.group('CURRENCY'), n.group('FEE'))
|
||||
except:
|
||||
#print "Unable to collect BuyIn/Fee Info"
|
||||
logging.info("Unable to collect BuyIn/Fee Info from HandInfo")
|
||||
if n.group('TURBO') is not None :
|
||||
hand.speed = "Turbo"
|
||||
if n.group('SPECIAL') is not None :
|
||||
special = n.group('SPECIAL')
|
||||
if special == "Rebuy":
|
||||
hand.isRebuy = True
|
||||
if special == "KO":
|
||||
hand.isKO = True
|
||||
if special == "Head's Up":
|
||||
hand.isHU = True
|
||||
if re.search("Matrix", special):
|
||||
hand.isMatrix = True
|
||||
if special == "Shootout":
|
||||
hand.isShootout = True
|
||||
|
||||
|
||||
if hand.buyin == None:
|
||||
hand.buyin = "$0.00+$0.00"
|
||||
|
@ -472,6 +493,8 @@ class Fulltilt(HandHistoryConverter):
|
|||
tourney.isMatrix = True
|
||||
if special == "Rebuy":
|
||||
tourney.isRebuy = True
|
||||
if special == "Madness":
|
||||
tourney.tourneyComment = "Madness"
|
||||
if mg['SHOOTOUT'] is not None:
|
||||
tourney.isShootout = True
|
||||
if mg['TURBO1'] is not None or mg['TURBO2'] is not None :
|
||||
|
|
|
@ -63,6 +63,15 @@ class Hand(object):
|
|||
self.fee = None # the Database code is looking for this one .. ?
|
||||
self.level = None
|
||||
self.mixed = None
|
||||
# Some attributes for hand from a tourney
|
||||
self.speed = "Normal"
|
||||
self.isRebuy = False
|
||||
self.isKO = False
|
||||
self.isHU = False
|
||||
self.isMatrix = False
|
||||
self.isShootout = False
|
||||
self.tourneyComment = None
|
||||
|
||||
self.seating = []
|
||||
self.players = []
|
||||
self.posted = []
|
||||
|
|
|
@ -2759,6 +2759,12 @@ class Sql:
|
|||
WHERE gametypeId=%s AND siteHandNo=%s
|
||||
"""
|
||||
|
||||
self.query['getTourneyTypeIdByTourneyNo'] = """SELECT tt.id
|
||||
FROM TourneyTypes tt
|
||||
INNER JOIN Tourneys t ON (t.tourneyTypeId = tt.id)
|
||||
WHERE t.siteTourneyNo=%s AND tt.siteId=%s
|
||||
"""
|
||||
|
||||
if db_server == 'mysql':
|
||||
self.query['placeholder'] = u'%s'
|
||||
elif db_server == 'postgresql':
|
||||
|
|
|
@ -46,7 +46,6 @@ class Tourney(object):
|
|||
|
||||
|
||||
def __init__(self, sitename, gametype, summaryText, builtFrom = "HHC"):
|
||||
print "Tourney.__init__"
|
||||
self.sitename = sitename
|
||||
self.siteId = self.SITEIDS[sitename]
|
||||
self.gametype = gametype
|
||||
|
@ -82,14 +81,13 @@ class Tourney(object):
|
|||
self.totalAddOns = 0
|
||||
self.koBounty = 0
|
||||
self.countKO = 0 #To use for winnings calculation which is not counted in the rest of the summary file
|
||||
self.tourneyComment = None
|
||||
self.players = []
|
||||
|
||||
# Collections indexed by player names
|
||||
self.finishPositions = {}
|
||||
self.winnings = {}
|
||||
|
||||
|
||||
|
||||
# currency symbol for this summary
|
||||
self.sym = None
|
||||
#self.sym = self.SYMBOL[self.gametype['currency']] # save typing! delete this attr when done
|
||||
|
@ -129,7 +127,8 @@ class Tourney(object):
|
|||
("TOTAL REBUYS", self.totalRebuys),
|
||||
("TOTAL ADDONS", self.totalAddOns),
|
||||
("KO BOUNTY", self.koBounty),
|
||||
("NB OF KO", self.countKO)
|
||||
("NB OF KO", self.countKO),
|
||||
("TOURNEY COMMENT", self.tourneyComment)
|
||||
)
|
||||
|
||||
structs = ( ("GAMETYPE", self.gametype),
|
||||
|
|
|
@ -67,7 +67,8 @@ def mainParser(settings, siteID, category, hand, config, db = None, writeq = Non
|
|||
tourneyStartTime= handStartTime #todo: read tourney start time
|
||||
rebuyOrAddon = fpdb_simple.isRebuyOrAddon(hand[0])
|
||||
|
||||
tourneyTypeId = fpdb_simple.recogniseTourneyTypeId(db.get_cursor(), siteID, buyin, fee, knockout, rebuyOrAddon)
|
||||
## The tourney site id has to be searched because it may already be in db with a TourneyTypeId which is different from the one automatically calculated (Summary import first)
|
||||
tourneyTypeId = fpdb_simple.recogniseTourneyTypeId(db, siteID, siteTourneyNo, buyin, fee, knockout, rebuyOrAddon)
|
||||
else:
|
||||
siteTourneyNo = -1
|
||||
buyin = -1
|
||||
|
|
|
@ -954,7 +954,17 @@ def recogniseGametypeID(backend, db, cursor, topline, smallBlindLine, site_id, c
|
|||
return result[0]
|
||||
#end def recogniseGametypeID
|
||||
|
||||
def recogniseTourneyTypeId(cursor, siteId, buyin, fee, knockout, rebuyOrAddon):
|
||||
def recogniseTourneyTypeId(db, siteId, tourneySiteId, buyin, fee, knockout, rebuyOrAddon):
|
||||
cursor = db.get_cursor()
|
||||
# First we try to find the tourney itself (by its tourneySiteId) in case it has already been inserted before (by a summary file for instance)
|
||||
# The reason is that some tourneys may not be identified correctly in the HH toplines (especially Buy-In and Fee which are used to search/create the TourneyTypeId)
|
||||
#TODO: When the summary file will be dumped to BD, if the tourney is already in, Buy-In/Fee may need an update (e.g. creation of a new type and link to the Tourney)
|
||||
cursor.execute (db.sql.query['getTourneyTypeIdByTourneyNo'].replace('%s', db.sql.query['placeholder']), (tourneySiteId, siteId))
|
||||
result=cursor.fetchone()
|
||||
|
||||
try:
|
||||
len(result)
|
||||
except:
|
||||
cursor.execute ("SELECT id FROM TourneyTypes WHERE siteId=%s AND buyin=%s AND fee=%s AND knockout=%s AND rebuyOrAddon=%s", (siteId, buyin, fee, knockout, rebuyOrAddon))
|
||||
result=cursor.fetchone()
|
||||
#print "tried SELECTing gametypes.id, result:",result
|
||||
|
@ -965,6 +975,7 @@ def recogniseTourneyTypeId(cursor, siteId, buyin, fee, knockout, rebuyOrAddon):
|
|||
cursor.execute("""INSERT INTO TourneyTypes (siteId, buyin, fee, knockout, rebuyOrAddon) VALUES (%s, %s, %s, %s, %s)""", (siteId, buyin, fee, knockout, rebuyOrAddon))
|
||||
cursor.execute("SELECT id FROM TourneyTypes WHERE siteId=%s AND buyin=%s AND fee=%s AND knockout=%s AND rebuyOrAddon=%s", (siteId, buyin, fee, knockout, rebuyOrAddon))
|
||||
result=cursor.fetchone()
|
||||
|
||||
return result[0]
|
||||
#end def recogniseTourneyTypeId
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user