Merge branch 'master' of git://git.assembla.com/mctfpdb
This commit is contained in:
commit
86fb5a0906
|
@ -27,7 +27,8 @@ from HandHistoryConverter import *
|
||||||
class Everleaf(HandHistoryConverter):
|
class Everleaf(HandHistoryConverter):
|
||||||
|
|
||||||
# Static regexes
|
# Static regexes
|
||||||
re_SplitHands = re.compile(r"(\n\n\n+)")
|
re_SplitHands = re.compile(r"\n\n\n+")
|
||||||
|
re_TailSplitHands = re.compile(r"(\n\n\n+)")
|
||||||
re_GameInfo = re.compile(ur"^(Blinds )?(?P<CURRENCY>\$| €|)(?P<SB>[.0-9]+)/(?:\$| €)?(?P<BB>[.0-9]+) (?P<LIMIT>NL|PL|) ?(?P<GAME>(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE)
|
re_GameInfo = re.compile(ur"^(Blinds )?(?P<CURRENCY>\$| €|)(?P<SB>[.0-9]+)/(?:\$| €)?(?P<BB>[.0-9]+) (?P<LIMIT>NL|PL|) ?(?P<GAME>(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE)
|
||||||
#re.compile(ur"^(Blinds )?(?P<CURRENCY>\$| €|)(?P<SB>[.0-9]+)/(?:\$| €)?(?P<BB>[.0-9]+) (?P<LIMIT>NL|PL|) (?P<GAME>(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE)
|
#re.compile(ur"^(Blinds )?(?P<CURRENCY>\$| €|)(?P<SB>[.0-9]+)/(?:\$| €)?(?P<BB>[.0-9]+) (?P<LIMIT>NL|PL|) (?P<GAME>(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE)
|
||||||
re_HandInfo = re.compile(ur".*#(?P<HID>[0-9]+)\n.*\n(Blinds )?(?:\$| €|)(?P<SB>[.0-9]+)/(?:\$| €|)(?P<BB>[.0-9]+) (?P<GAMETYPE>.*) - (?P<DATETIME>\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P<TABLE>.+$)", re.MULTILINE)
|
re_HandInfo = re.compile(ur".*#(?P<HID>[0-9]+)\n.*\n(Blinds )?(?:\$| €|)(?P<SB>[.0-9]+)/(?:\$| €|)(?P<BB>[.0-9]+) (?P<GAMETYPE>.*) - (?P<DATETIME>\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P<TABLE>.+$)", re.MULTILINE)
|
||||||
|
|
|
@ -28,11 +28,13 @@ class Fulltilt(HandHistoryConverter):
|
||||||
|
|
||||||
# Static regexes
|
# Static regexes
|
||||||
re_GameInfo = re.compile('- (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (Ante \$(?P<ANTE>[.0-9]+) )?- (?P<LIMIT>(No Limit|Pot Limit|Limit))? (?P<GAME>(Hold\'em|Omaha Hi|Razz))')
|
re_GameInfo = re.compile('- (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (Ante \$(?P<ANTE>[.0-9]+) )?- (?P<LIMIT>(No Limit|Pot Limit|Limit))? (?P<GAME>(Hold\'em|Omaha Hi|Razz))')
|
||||||
re_SplitHands = re.compile(r"(\n\n+)")
|
re_SplitHands = re.compile(r"\n\n+")
|
||||||
|
re_TailSplitHands = re.compile(r"(\n\n+)")
|
||||||
re_HandInfo = re.compile('.*#(?P<HID>[0-9]+): Table (?P<TABLE>[- a-zA-Z]+) (\((?P<TABLEATTRIBUTES>.+)\) )?- \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (Ante \$(?P<ANTE>[.0-9]+) )?- (?P<GAMETYPE>[a-zA-Z\' ]+) - (?P<DATETIME>.*)')
|
re_HandInfo = re.compile('.*#(?P<HID>[0-9]+): Table (?P<TABLE>[- a-zA-Z]+) (\((?P<TABLEATTRIBUTES>.+)\) )?- \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (Ante \$(?P<ANTE>[.0-9]+) )?- (?P<GAMETYPE>[a-zA-Z\' ]+) - (?P<DATETIME>.*)')
|
||||||
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]+)\)\n')
|
re_PlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$(?P<CASH>[.0-9]+)\)\n')
|
||||||
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
||||||
|
# NB: if we ever match "Full Tilt Poker" we should also match "FullTiltPoker", which PT Stud erroneously exports.
|
||||||
|
|
||||||
def __init__(self, in_path = '-', out_path = '-', follow = False, autostart=True):
|
def __init__(self, in_path = '-', out_path = '-', follow = False, autostart=True):
|
||||||
"""\
|
"""\
|
||||||
|
|
|
@ -112,7 +112,9 @@ class HandHistoryConverter():
|
||||||
def start(self):
|
def start(self):
|
||||||
"""process a hand at a time from the input specified by in_path.
|
"""process a hand at a time from the input specified by in_path.
|
||||||
If in follow mode, wait for more data to turn up.
|
If in follow mode, wait for more data to turn up.
|
||||||
Otherwise, finish at eof..."""
|
Otherwise, finish at eof...
|
||||||
|
|
||||||
|
"""
|
||||||
starttime = time.time()
|
starttime = time.time()
|
||||||
if not self.sanityCheck():
|
if not self.sanityCheck():
|
||||||
print "Cowardly refusing to continue after failed sanity check"
|
print "Cowardly refusing to continue after failed sanity check"
|
||||||
|
@ -137,7 +139,11 @@ Otherwise, finish at eof..."""
|
||||||
|
|
||||||
def tailHands(self):
|
def tailHands(self):
|
||||||
"""Generator of handTexts from a tailed file:
|
"""Generator of handTexts from a tailed file:
|
||||||
Tail the in_path file and yield handTexts separated by re_SplitHands"""
|
Tail the in_path file and yield handTexts separated by re_SplitHands.
|
||||||
|
This requires a regex that greedily groups and matches the 'splitter' between hands,
|
||||||
|
which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py.
|
||||||
|
|
||||||
|
"""
|
||||||
if self.in_path == '-': raise StopIteration
|
if self.in_path == '-': raise StopIteration
|
||||||
interval = 1.0 # seconds to sleep between reads for new data
|
interval = 1.0 # seconds to sleep between reads for new data
|
||||||
fd = codecs.open(self.in_path,'r', self.codepage)
|
fd = codecs.open(self.in_path,'r', self.codepage)
|
||||||
|
@ -161,7 +167,7 @@ Tail the in_path file and yield handTexts separated by re_SplitHands"""
|
||||||
else:
|
else:
|
||||||
# yield hands
|
# yield hands
|
||||||
data = data + newdata
|
data = data + newdata
|
||||||
result = self.re_SplitHands.split(data)
|
result = self.re_TailSplitHands.split(data)
|
||||||
result = iter(result)
|
result = iter(result)
|
||||||
data = ''
|
data = ''
|
||||||
# --x data (- is bit of splitter, x is paragraph) yield,...,keep
|
# --x data (- is bit of splitter, x is paragraph) yield,...,keep
|
||||||
|
|
|
@ -27,7 +27,8 @@ class PokerStars(HandHistoryConverter):
|
||||||
|
|
||||||
# Static regexes
|
# Static regexes
|
||||||
re_GameInfo = re.compile("PokerStars Game #(?P<HID>[0-9]+):\s+(HORSE)? \(?(?P<GAME>Hold\'em|Razz|7 Card Stud|Omaha|Omaha Hi/Lo|Badugi) (?P<LIMIT>No Limit|Limit|Pot Limit),? \(?(?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+)\) - (?P<DATETIME>.*$)", re.MULTILINE)
|
re_GameInfo = re.compile("PokerStars Game #(?P<HID>[0-9]+):\s+(HORSE)? \(?(?P<GAME>Hold\'em|Razz|7 Card Stud|Omaha|Omaha Hi/Lo|Badugi) (?P<LIMIT>No Limit|Limit|Pot Limit),? \(?(?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+)\) - (?P<DATETIME>.*$)", re.MULTILINE)
|
||||||
re_SplitHands = re.compile('(\n\n+)')
|
re_SplitHands = re.compile('\n\n+')
|
||||||
|
re_TailSplitHands = re.compile('(\n\n\n+)')
|
||||||
re_HandInfo = re.compile("^Table \'(?P<TABLE>[- a-zA-Z]+)\'(?P<TABLEATTRIBUTES>.+?$)?", re.MULTILINE)
|
re_HandInfo = re.compile("^Table \'(?P<TABLE>[- a-zA-Z]+)\'(?P<TABLEATTRIBUTES>.+?$)?", re.MULTILINE)
|
||||||
re_Button = re.compile('Seat #(?P<BUTTON>\d+) is the button', re.MULTILINE)
|
re_Button = re.compile('Seat #(?P<BUTTON>\d+) is the button', re.MULTILINE)
|
||||||
re_PlayerInfo = re.compile('^Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$?(?P<CASH>[.0-9]+) in chips\)', re.MULTILINE)
|
re_PlayerInfo = re.compile('^Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$?(?P<CASH>[.0-9]+) in chips\)', re.MULTILINE)
|
||||||
|
|
|
@ -46,7 +46,7 @@ def testGameInfo():
|
||||||
|
|
||||||
|
|
||||||
def testHandInfo():
|
def testHandInfo():
|
||||||
text = u""""PokerStars Game #20461877044: Hold'em No Limit ($1/$2) - 2008/09/16 18:58:01 ET"""
|
text = u"""PokerStars Game #20461877044: Hold'em No Limit ($1/$2) - 2008/09/16 18:58:01 ET"""
|
||||||
hhc = PokerStarsToFpdb.PokerStars(autostart=False)
|
hhc = PokerStarsToFpdb.PokerStars(autostart=False)
|
||||||
h = HoldemOmahaHand(None, "PokerStars", gametype, text, builtFrom = "Test")
|
h = HoldemOmahaHand(None, "PokerStars", gametype, text, builtFrom = "Test")
|
||||||
hhc.readHandInfo(h)
|
hhc.readHandInfo(h)
|
||||||
|
@ -78,4 +78,4 @@ Table 'Caia II' 6-max Seat #2 is the button"""
|
||||||
assert h.buttonpos == '2' # TODO: should this be an int?
|
assert h.buttonpos == '2' # TODO: should this be an int?
|
||||||
assert h.starttime == (2008,11 , 15, 19, 22, 21, 5, 320, -1)
|
assert h.starttime == (2008,11 , 15, 19, 22, 21, 5, 320, -1)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,25 +16,24 @@ def testPokerStarsHHDate():
|
||||||
datetime.datetime(2008,9,7,11,23,14))
|
datetime.datetime(2008,9,7,11,23,14))
|
||||||
)
|
)
|
||||||
|
|
||||||
#def testFullTiltHHDate(self):
|
def testFullTiltHHDate():
|
||||||
# sitngo1 = "Full Tilt Poker Game #10311865543: $1 + $0.25 Sit & Go (78057629), Table 1 - 25/50 - No Limit Hold'em - 0:07:45 ET - 2009/01/29"
|
sitngo1 = "Full Tilt Poker Game #10311865543: $1 + $0.25 Sit & Go (78057629), Table 1 - 25/50 - No Limit Hold'em - 0:07:45 ET - 2009/01/29"
|
||||||
# cash1 = "Full Tilt Poker Game #9403951181: Table CR - tay - $0.05/$0.10 - No Limit Hold'em - 9:40:20 ET - 2008/12/09"
|
cash1 = "Full Tilt Poker Game #9403951181: Table CR - tay - $0.05/$0.10 - No Limit Hold'em - 9:40:20 ET - 2008/12/09"
|
||||||
# cash2 = "Full Tilt Poker Game #9468383505: Table Bike (deep 6) - $0.05/$0.10 - No Limit Hold'em - 5:09:36 ET - 2008/12/13"
|
cash2 = "Full Tilt Poker Game #9468383505: Table Bike (deep 6) - $0.05/$0.10 - No Limit Hold'em - 5:09:36 ET - 2008/12/13"
|
||||||
|
|
||||||
# result = fpdb_simple.parseHandStartTime(sitngo1,"ftp")
|
result = fpdb_simple.parseHandStartTime(sitngo1,"ftp")
|
||||||
# self.failUnless(result==datetime.datetime(2009,1,29,05,07,45),
|
assert result==datetime.datetime(2009,1,29,05,07,45)
|
||||||
# "Date incorrect, expected: 2009-01-29 05:07:45 got: " + str(result))
|
result = fpdb_simple.parseHandStartTime(cash1,"ftp")
|
||||||
# result = fpdb_simple.parseHandStartTime(cash1,"ftp")
|
assert result==datetime.datetime(2008,12,9,14,40,20)
|
||||||
# self.failUnless(result==datetime.datetime(2008,12,9,14,40,20),
|
result = fpdb_simple.parseHandStartTime(cash2,"ftp")
|
||||||
# "Date incorrect, expected: 2008-12-09 14:40:20 got: " + str(result))
|
assert result==datetime.datetime(2008,12,13,10,9,36)
|
||||||
# result = fpdb_simple.parseHandStartTime(cash2,"ftp")
|
|
||||||
# self.failUnless(result==datetime.datetime(2008,12,13,10,9,36),
|
|
||||||
# "Date incorrect, expected: 2008-12-13 10:09:36 got: " + str(result))
|
|
||||||
|
|
||||||
# def testTableDetection(self):
|
def testTableDetection():
|
||||||
# result = Tables.clean_title("French (deep)")
|
result = Tables.clean_title("French (deep)")
|
||||||
# self.failUnless(result == "French", "French (deep) parsed incorrectly. Expected 'French' got: " + str(result))
|
assert result == "French"
|
||||||
# result = ("French (deep) - $0.25/$0.50 - No Limit Hold'em - Logged In As xxxx")
|
result = Tables.clean_title("French (deep) - $0.25/$0.50 - No Limit Hold'em - Logged In As xxxx")
|
||||||
|
assert result == "French"
|
||||||
|
|
||||||
|
for (header, site, result) in tuples:
|
||||||
|
yield checkDateParse, header, site, result
|
||||||
|
|
||||||
for (header, site, result) in tuples:
|
|
||||||
yield checkDateParse, header, site, result
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user