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
|
(?P<PARTIAL>\(partial\))?\n
|
||||||
(?:.*?\n(?P<CANCELLED>Hand\s\#(?P=HID)\shas\sbeen\scanceled))?
|
(?:.*?\n(?P<CANCELLED>Hand\s\#(?P=HID)\shas\sbeen\scanceled))?
|
||||||
''', re.VERBOSE|re.DOTALL)
|
''', 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_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_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)
|
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
|
re_TourneyInfo = re.compile('''Tournament\sSummary\s
|
||||||
(?P<TOURNAMENT_NAME>[^$(]+)?\s*
|
(?P<TOURNAMENT_NAME>[^$(]+)?\s*
|
||||||
((?P<CURRENCY>\$|)?(?P<BUYIN>[.0-9]+)\s*\+\s*\$?(?P<FEE>[.0-9]+)\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<SHOOTOUT>Shootout)\s)?
|
||||||
((?P<SNG>Sit\s&\sGo)\s)?
|
((?P<SNG>Sit\s&\sGo)\s)?
|
||||||
(\((?P<TURBO1>Turbo)\)\s)?
|
(\((?P<TURBO1>Turbo)\)\s)?
|
||||||
|
@ -202,16 +209,30 @@ class Fulltilt(HandHistoryConverter):
|
||||||
if m.group('PLAY') != None:
|
if m.group('PLAY') != None:
|
||||||
hand.gametype['currency'] = 'play'
|
hand.gametype['currency'] = 'play'
|
||||||
|
|
||||||
# TODO: if there's a way to figure these out, we should.. otherwise we have to stuff it with unknowns
|
# Done: 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&()]+)?''')
|
if m.group('TOURNAMENT') is not None:
|
||||||
# TO DO : See if important info can be retrieved from EXTRA_INFO (sould be things like Turbo, Matrix, KO, ...)
|
n = self.re_TourneyExtraInfo.search(m.group('TOURNAMENT'))
|
||||||
try:
|
if n.group('UNREADABLE_INFO') is not None:
|
||||||
n = re_SNGBuyInFee.search(m.group('TOURNAMENT'))
|
hand.tourneyComment = n.group('UNREADABLE_INFO')
|
||||||
#print "cur %s BUYIN %s FEE %s EXTRA %s" %(n.group('CURRENCY'), n.group('BUYIN'), n.group('FEE'), n.group('EXTRA_INFO'))
|
else:
|
||||||
hand.buyin = "%s%s+%s%s" %(n.group('CURRENCY'), n.group('BUYIN'), n.group('CURRENCY'), n.group('FEE'))
|
hand.tourneyComment = n.group('TOURNEY_NAME') # can be None
|
||||||
except:
|
if (n.group('CURRENCY') is not None and n.group('BUYIN') is not None and n.group('FEE') is not None):
|
||||||
#print "Unable to collect BuyIn/Fee Info"
|
hand.buyin = "%s%s+%s%s" %(n.group('CURRENCY'), n.group('BUYIN'), n.group('CURRENCY'), n.group('FEE'))
|
||||||
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:
|
if hand.buyin == None:
|
||||||
hand.buyin = "$0.00+$0.00"
|
hand.buyin = "$0.00+$0.00"
|
||||||
|
@ -472,6 +493,8 @@ class Fulltilt(HandHistoryConverter):
|
||||||
tourney.isMatrix = True
|
tourney.isMatrix = True
|
||||||
if special == "Rebuy":
|
if special == "Rebuy":
|
||||||
tourney.isRebuy = True
|
tourney.isRebuy = True
|
||||||
|
if special == "Madness":
|
||||||
|
tourney.tourneyComment = "Madness"
|
||||||
if mg['SHOOTOUT'] is not None:
|
if mg['SHOOTOUT'] is not None:
|
||||||
tourney.isShootout = True
|
tourney.isShootout = True
|
||||||
if mg['TURBO1'] is not None or mg['TURBO2'] is not None :
|
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.fee = None # the Database code is looking for this one .. ?
|
||||||
self.level = None
|
self.level = None
|
||||||
self.mixed = 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.seating = []
|
||||||
self.players = []
|
self.players = []
|
||||||
self.posted = []
|
self.posted = []
|
||||||
|
|
|
@ -2758,6 +2758,12 @@ class Sql:
|
||||||
self.query['isAlreadyInDB'] = """SELECT id FROM Hands
|
self.query['isAlreadyInDB'] = """SELECT id FROM Hands
|
||||||
WHERE gametypeId=%s AND siteHandNo=%s
|
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':
|
if db_server == 'mysql':
|
||||||
self.query['placeholder'] = u'%s'
|
self.query['placeholder'] = u'%s'
|
||||||
|
|
|
@ -46,7 +46,6 @@ class Tourney(object):
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, sitename, gametype, summaryText, builtFrom = "HHC"):
|
def __init__(self, sitename, gametype, summaryText, builtFrom = "HHC"):
|
||||||
print "Tourney.__init__"
|
|
||||||
self.sitename = sitename
|
self.sitename = sitename
|
||||||
self.siteId = self.SITEIDS[sitename]
|
self.siteId = self.SITEIDS[sitename]
|
||||||
self.gametype = gametype
|
self.gametype = gametype
|
||||||
|
@ -82,14 +81,13 @@ class Tourney(object):
|
||||||
self.totalAddOns = 0
|
self.totalAddOns = 0
|
||||||
self.koBounty = 0
|
self.koBounty = 0
|
||||||
self.countKO = 0 #To use for winnings calculation which is not counted in the rest of the summary file
|
self.countKO = 0 #To use for winnings calculation which is not counted in the rest of the summary file
|
||||||
|
self.tourneyComment = None
|
||||||
self.players = []
|
self.players = []
|
||||||
|
|
||||||
# Collections indexed by player names
|
# Collections indexed by player names
|
||||||
self.finishPositions = {}
|
self.finishPositions = {}
|
||||||
self.winnings = {}
|
self.winnings = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 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
|
#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 REBUYS", self.totalRebuys),
|
||||||
("TOTAL ADDONS", self.totalAddOns),
|
("TOTAL ADDONS", self.totalAddOns),
|
||||||
("KO BOUNTY", self.koBounty),
|
("KO BOUNTY", self.koBounty),
|
||||||
("NB OF KO", self.countKO)
|
("NB OF KO", self.countKO),
|
||||||
|
("TOURNEY COMMENT", self.tourneyComment)
|
||||||
)
|
)
|
||||||
|
|
||||||
structs = ( ("GAMETYPE", self.gametype),
|
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
|
tourneyStartTime= handStartTime #todo: read tourney start time
|
||||||
rebuyOrAddon = fpdb_simple.isRebuyOrAddon(hand[0])
|
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:
|
else:
|
||||||
siteTourneyNo = -1
|
siteTourneyNo = -1
|
||||||
buyin = -1
|
buyin = -1
|
||||||
|
|
|
@ -954,17 +954,28 @@ def recogniseGametypeID(backend, db, cursor, topline, smallBlindLine, site_id, c
|
||||||
return result[0]
|
return result[0]
|
||||||
#end def recogniseGametypeID
|
#end def recogniseGametypeID
|
||||||
|
|
||||||
def recogniseTourneyTypeId(cursor, siteId, buyin, fee, knockout, rebuyOrAddon):
|
def recogniseTourneyTypeId(db, siteId, tourneySiteId, 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))
|
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()
|
result=cursor.fetchone()
|
||||||
#print "tried SELECTing gametypes.id, result:",result
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
len(result)
|
len(result)
|
||||||
except TypeError:#this means we need to create a new entry
|
except:
|
||||||
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))
|
||||||
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()
|
result=cursor.fetchone()
|
||||||
|
#print "tried SELECTing gametypes.id, result:",result
|
||||||
|
|
||||||
|
try:
|
||||||
|
len(result)
|
||||||
|
except TypeError:#this means we need to create a new entry
|
||||||
|
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]
|
return result[0]
|
||||||
#end def recogniseTourneyTypeId
|
#end def recogniseTourneyTypeId
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user