Betfair: Fix some error handling in legacy parser

This commit is contained in:
Worros 2010-09-06 17:25:17 +08:00
parent c7072bdd84
commit e24e722141

View File

@ -44,7 +44,7 @@ class Betfair(HandHistoryConverter):
siteId = 7 # Needs to match id entry in Sites database
# Static regexes
re_GameInfo = re.compile("^(?P<LIMIT>NL|PL|) (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<GAME>(Texas Hold\'em|Omaha Hi|Razz))", re.MULTILINE)
re_GameInfo = re.compile("^(?P<LIMIT>NL|PL|) (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<GAME>(Texas Hold\'em|Omaha Hi|Omaha|Razz))", re.MULTILINE)
re_SplitHands = re.compile(r'\n\n+')
re_HandInfo = re.compile("\*\*\*\*\* Betfair Poker Hand History for Game (?P<HID>[0-9]+) \*\*\*\*\*\n(?P<LIMIT>NL|PL|) (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<GAMETYPE>(Texas Hold\'em|Omaha Hi|Razz)) - (?P<DATETIME>[a-zA-Z]+, [a-zA-Z]+ \d+, \d\d:\d\d:\d\d GMT \d\d\d\d)\nTable (?P<TABLE>[ a-zA-Z0-9]+) \d-max \(Real Money\)\nSeat (?P<BUTTON>[0-9]+)", re.MULTILINE)
re_Button = re.compile(ur"^Seat (?P<BUTTON>\d+) is the button", re.MULTILINE)
@ -72,7 +72,8 @@ class Betfair(HandHistoryConverter):
self.re_ShownCards = re.compile(r"%s (?P<SEAT>[0-9]+) (?P<CARDS>adsfasdf)" % player_re, re.MULTILINE)
def readSupportedGames(self):
return [["ring", "hold", "nl"]
return [["ring", "hold", "nl"],
["ring", "hold", "pl"]
]
def determineGameType(self, handText):
@ -80,8 +81,10 @@ class Betfair(HandHistoryConverter):
m = self.re_GameInfo.search(handText)
if not m:
logging.info(_('GameInfo regex did not match'))
return None
tmp = handText[0:100]
log.error(_("determineGameType: Unable to recognise gametype from: '%s'") % tmp)
log.error(_("determineGameType: Raising FpdbParseError"))
raise FpdbParseError(_("Unable to recognise gametype from: '%s'") % tmp)
mg = m.groupdict()
@ -90,6 +93,7 @@ class Betfair(HandHistoryConverter):
games = { # base, category
"Texas Hold'em" : ('hold','holdem'),
'Omaha Hi' : ('hold','omahahi'),
'Omaha' : ('hold','omahahi'),
'Razz' : ('stud','razz'),
'7 Card Stud' : ('stud','studhi')
}
@ -104,16 +108,15 @@ class Betfair(HandHistoryConverter):
info['bb'] = mg['BB']
if 'CURRENCY' in mg:
info['currency'] = currencies[mg['CURRENCY']]
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
return info
def readHandInfo(self, hand):
m = self.re_HandInfo.search(hand.handText)
if(m == None):
logging.info(_("Didn't match re_HandInfo"))
logging.info(hand.handText)
return None
log.error(_("Didn't match re_HandInfo"))
raise FpdbParseError("No match in readHandInfo.")
print "DEBUG: got this far!"
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
hand.handid = m.group('HID')
hand.tablename = m.group('TABLE')