Merge branch 'master' of git://git.assembla.com/fpdboz
This commit is contained in:
commit
6667f4cddb
|
@ -18,6 +18,7 @@
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import logging
|
||||||
import Configuration
|
import Configuration
|
||||||
from HandHistoryConverter import *
|
from HandHistoryConverter import *
|
||||||
from time import strftime
|
from time import strftime
|
||||||
|
@ -28,13 +29,12 @@ class Everleaf(HandHistoryConverter):
|
||||||
|
|
||||||
# Static regexes
|
# Static regexes
|
||||||
re_SplitHands = re.compile(r"\n\n+")
|
re_SplitHands = re.compile(r"\n\n+")
|
||||||
re_GameInfo = re.compile(r".*Blinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<LTYPE>(NL|PL)) (?P<GAME>(Hold\'em|Omaha|7 Card Stud))")
|
re_GameInfo = re.compile(r"^(Blinds )?\$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) ((?P<LTYPE>NL|PL) )?(?P<GAME>(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE)
|
||||||
re_HandInfo = re.compile(r".*#(?P<HID>[0-9]+)\n.*\nBlinds \$?(?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>[- a-zA-Z]+)")
|
re_HandInfo = re.compile(r".*#(?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>[- a-zA-Z]+)")
|
||||||
re_Button = re.compile(r"^Seat (?P<BUTTON>\d+) is the button", re.MULTILINE)
|
re_Button = re.compile(r"^Seat (?P<BUTTON>\d+) is the button", re.MULTILINE)
|
||||||
re_PlayerInfo = re.compile(r"^Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\s+(\$ (?P<CASH>[.0-9]+) USD|new player|All-in) \)", re.MULTILINE)
|
re_PlayerInfo = re.compile(r"^Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\s+(\$ (?P<CASH>[.0-9]+) USD|new player|All-in) \)", re.MULTILINE)
|
||||||
re_Board = re.compile(r"\[ (?P<CARDS>.+) \]")
|
re_Board = re.compile(r"\[ (?P<CARDS>.+) \]")
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, config, file):
|
def __init__(self, config, file):
|
||||||
print "Initialising Everleaf converter class"
|
print "Initialising Everleaf converter class"
|
||||||
HandHistoryConverter.__init__(self, config, file, sitename="Everleaf") # Call super class init.
|
HandHistoryConverter.__init__(self, config, file, sitename="Everleaf") # Call super class init.
|
||||||
|
@ -62,10 +62,11 @@ class Everleaf(HandHistoryConverter):
|
||||||
def readSupportedGames(self):
|
def readSupportedGames(self):
|
||||||
return [["ring", "hold", "nl"],
|
return [["ring", "hold", "nl"],
|
||||||
["ring", "hold", "pl"],
|
["ring", "hold", "pl"],
|
||||||
["ring", "omaha", "pl"]
|
["ring", "hold", "fl"],
|
||||||
|
["ring", "omahahi", "pl"]
|
||||||
]
|
]
|
||||||
|
|
||||||
def determineGameType(self):
|
def determineGameType(self, handText):
|
||||||
# Cheating with this regex, only support nlhe at the moment
|
# Cheating with this regex, only support nlhe at the moment
|
||||||
# Blinds $0.50/$1 PL Omaha - 2008/12/07 - 21:59:48
|
# Blinds $0.50/$1 PL Omaha - 2008/12/07 - 21:59:48
|
||||||
# Blinds $0.05/$0.10 NL Hold'em - 2009/02/21 - 11:21:57
|
# Blinds $0.05/$0.10 NL Hold'em - 2009/02/21 - 11:21:57
|
||||||
|
@ -80,8 +81,9 @@ class Everleaf(HandHistoryConverter):
|
||||||
structure = "" # nl, pl, cn, cp, fl
|
structure = "" # nl, pl, cn, cp, fl
|
||||||
game = ""
|
game = ""
|
||||||
|
|
||||||
m = self.re_GameInfo.search(self.obs)
|
m = self.re_GameInfo.search(handText)
|
||||||
if m == None:
|
if m == None:
|
||||||
|
logging.debug("Gametype didn't match")
|
||||||
return None
|
return None
|
||||||
if m.group('LTYPE') == "NL":
|
if m.group('LTYPE') == "NL":
|
||||||
structure = "nl"
|
structure = "nl"
|
||||||
|
@ -102,45 +104,45 @@ class Everleaf(HandHistoryConverter):
|
||||||
return gametype
|
return gametype
|
||||||
|
|
||||||
def readHandInfo(self, hand):
|
def readHandInfo(self, hand):
|
||||||
m = self.re_HandInfo.search(hand.string)
|
m = self.re_HandInfo.search(hand.handText)
|
||||||
if(m == None):
|
if(m == None):
|
||||||
print "DEBUG: re_HandInfo.search failed: '%s'" %(hand.string)
|
logging.info("Didn't match re_HandInfo")
|
||||||
|
logging.info(hand.handtext)
|
||||||
|
return None
|
||||||
|
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
|
||||||
hand.handid = m.group('HID')
|
hand.handid = m.group('HID')
|
||||||
hand.tablename = m.group('TABLE')
|
hand.tablename = m.group('TABLE')
|
||||||
hand.max_seats = 6 # assume 6-max unless we have proof it's a larger/smaller game, since everleaf doesn't give seat max info
|
hand.maxseats = 6 # assume 6-max unless we have proof it's a larger/smaller game, since everleaf doesn't give seat max info
|
||||||
# These work, but the info is already in the Hand class - should be used for tourneys though.
|
|
||||||
# m.group('SB')
|
|
||||||
# m.group('BB')
|
|
||||||
# m.group('GAMETYPE')
|
|
||||||
|
|
||||||
# Believe Everleaf time is GMT/UTC, no transation necessary
|
# Believe Everleaf time is GMT/UTC, no transation necessary
|
||||||
# Stars format (Nov 10 2008): 2008/11/07 12:38:49 CET [2008/11/07 7:38:49 ET]
|
# Stars format (Nov 10 2008): 2008/11/07 12:38:49 CET [2008/11/07 7:38:49 ET]
|
||||||
# or : 2008/11/07 12:38:49 ET
|
# or : 2008/11/07 12:38:49 ET
|
||||||
# Not getting it in my HH files yet, so using
|
# Not getting it in my HH files yet, so using
|
||||||
# 2008/11/10 3:58:52 ET
|
# 2008/11/10 3:58:52 ET
|
||||||
#TODO: Do conversion from GMT to ET
|
#TODO: Do conversion from GMT to ET
|
||||||
#TODO: Need some date functions to convert to different timezones (Date::Manip for perl rocked for this)
|
#TODO: Need some date functions to convert to different timezones (Date::Manip for perl rocked for this)
|
||||||
hand.starttime = time.strptime(m.group('DATETIME'), "%Y/%m/%d - %H:%M:%S")
|
hand.starttime = time.strptime(m.group('DATETIME'), "%Y/%m/%d - %H:%M:%S")
|
||||||
|
return
|
||||||
|
|
||||||
def readPlayerStacks(self, hand):
|
def readPlayerStacks(self, hand):
|
||||||
m = self.re_PlayerInfo.finditer(hand.string)
|
m = self.re_PlayerInfo.finditer(hand.handText)
|
||||||
for a in m:
|
for a in m:
|
||||||
seatnum = int(a.group('SEAT'))
|
seatnum = int(a.group('SEAT'))
|
||||||
hand.addPlayer(seatnum, a.group('PNAME'), a.group('CASH'))
|
hand.addPlayer(seatnum, a.group('PNAME'), a.group('CASH'))
|
||||||
if seatnum > 6:
|
if seatnum > 6:
|
||||||
hand.max_seats = 10 # everleaf currently does 2/6/10 games, so if seats > 6 are in use, it must be 10-max.
|
hand.maxseats = 10 # everleaf currently does 2/6/10 games, so if seats > 6 are in use, it must be 10-max.
|
||||||
# TODO: implement lookup list by table-name to determine maxes, then fall back to 6 default/10 here, if there's no entry in the list?
|
# TODO: implement lookup list by table-name to determine maxes, then fall back to 6 default/10 here, if there's no entry in the list?
|
||||||
|
|
||||||
|
|
||||||
def markStreets(self, hand):
|
def markStreets(self, hand):
|
||||||
# PREFLOP = ** Dealing down cards **
|
# PREFLOP = ** Dealing down cards **
|
||||||
# This re fails if, say, river is missing; then we don't get the ** that starts the river.
|
# This re fails if, say, river is missing; then we don't get the ** that starts the river.
|
||||||
#m = re.search('(\*\* Dealing down cards \*\*\n)(?P<PREFLOP>.*?\n\*\*)?( Dealing Flop \*\* \[ (?P<FLOP1>\S\S), (?P<FLOP2>\S\S), (?P<FLOP3>\S\S) \])?(?P<FLOP>.*?\*\*)?( Dealing Turn \*\* \[ (?P<TURN1>\S\S) \])?(?P<TURN>.*?\*\*)?( Dealing River \*\* \[ (?P<RIVER1>\S\S) \])?(?P<RIVER>.*)', hand.string,re.DOTALL)
|
#m = re.search('(\*\* Dealing down cards \*\*\n)(?P<PREFLOP>.*?\n\*\*)?( Dealing Flop \*\* \[ (?P<FLOP1>\S\S), (?P<FLOP2>\S\S), (?P<FLOP3>\S\S) \])?(?P<FLOP>.*?\*\*)?( Dealing Turn \*\* \[ (?P<TURN1>\S\S) \])?(?P<TURN>.*?\*\*)?( Dealing River \*\* \[ (?P<RIVER1>\S\S) \])?(?P<RIVER>.*)', hand.handText,re.DOTALL)
|
||||||
|
|
||||||
m = re.search(r"\*\* Dealing down cards \*\*(?P<PREFLOP>.+(?=\*\* Dealing Flop \*\*)|.+)"
|
m = re.search(r"\*\* Dealing down cards \*\*(?P<PREFLOP>.+(?=\*\* Dealing Flop \*\*)|.+)"
|
||||||
r"(\*\* Dealing Flop \*\*(?P<FLOP> \[ \S\S, \S\S, \S\S \].+(?=\*\* Dealing Turn \*\*)|.+))?"
|
r"(\*\* Dealing Flop \*\*(?P<FLOP> \[ \S\S, \S\S, \S\S \].+(?=\*\* Dealing Turn \*\*)|.+))?"
|
||||||
r"(\*\* Dealing Turn \*\*(?P<TURN> \[ \S\S \].+(?=\*\* Dealing River \*\*)|.+))?"
|
r"(\*\* Dealing Turn \*\*(?P<TURN> \[ \S\S \].+(?=\*\* Dealing River \*\*)|.+))?"
|
||||||
r"(\*\* Dealing River \*\*(?P<RIVER> \[ \S\S \].+))?", hand.string,re.DOTALL)
|
r"(\*\* Dealing River \*\*(?P<RIVER> \[ \S\S \].+))?", hand.handText,re.DOTALL)
|
||||||
|
|
||||||
hand.addStreets(m)
|
hand.addStreets(m)
|
||||||
|
|
||||||
|
@ -153,34 +155,35 @@ class Everleaf(HandHistoryConverter):
|
||||||
hand.setCommunityCards(street, m.group('CARDS').split(', '))
|
hand.setCommunityCards(street, m.group('CARDS').split(', '))
|
||||||
|
|
||||||
def readBlinds(self, hand):
|
def readBlinds(self, hand):
|
||||||
try:
|
m = self.re_PostSB.search(hand.handText)
|
||||||
m = self.re_PostSB.search(hand.string)
|
if m is not None:
|
||||||
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
||||||
except Exception, e: # no small blind
|
else:
|
||||||
#print e
|
logging.debug("No small blind")
|
||||||
hand.addBlind(None, None, None)
|
hand.addBlind(None, None, None)
|
||||||
for a in self.re_PostBB.finditer(hand.string):
|
for a in self.re_PostBB.finditer(hand.handText):
|
||||||
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
||||||
for a in self.re_PostBoth.finditer(hand.string):
|
for a in self.re_PostBoth.finditer(hand.handText):
|
||||||
hand.addBlind(a.group('PNAME'), 'both', a.group('SBBB'))
|
hand.addBlind(a.group('PNAME'), 'both', a.group('SBBB'))
|
||||||
|
|
||||||
def readButton(self, hand):
|
def readButton(self, hand):
|
||||||
hand.buttonpos = int(self.re_Button.search(hand.string).group('BUTTON'))
|
hand.buttonpos = int(self.re_Button.search(hand.handText).group('BUTTON'))
|
||||||
|
|
||||||
def readHeroCards(self, hand):
|
def readHeroCards(self, hand):
|
||||||
m = self.re_HeroCards.search(hand.string)
|
m = self.re_HeroCards.search(hand.handText)
|
||||||
if(m == None):
|
if m:
|
||||||
#Not involved in hand
|
|
||||||
hand.involved = False
|
|
||||||
else:
|
|
||||||
hand.hero = m.group('PNAME')
|
hand.hero = m.group('PNAME')
|
||||||
# "2c, qh" -> set(["2c","qc"])
|
# "2c, qh" -> ["2c","qc"]
|
||||||
# Also works with Omaha hands.
|
# Also works with Omaha hands.
|
||||||
cards = m.group('CARDS')
|
cards = m.group('CARDS')
|
||||||
cards = cards.split(', ')
|
cards = cards.split(', ')
|
||||||
hand.addHoleCards(cards, m.group('PNAME'))
|
hand.addHoleCards(cards, m.group('PNAME'))
|
||||||
|
else:
|
||||||
|
#Not involved in hand
|
||||||
|
hand.involved = False
|
||||||
|
|
||||||
def readAction(self, hand, street):
|
def readAction(self, hand, street):
|
||||||
|
logging.debug("readAction (%s)" % street)
|
||||||
m = self.re_Action.finditer(hand.streets.group(street))
|
m = self.re_Action.finditer(hand.streets.group(street))
|
||||||
for action in m:
|
for action in m:
|
||||||
if action.group('ATYPE') == ' raises':
|
if action.group('ATYPE') == ' raises':
|
||||||
|
@ -194,26 +197,30 @@ class Everleaf(HandHistoryConverter):
|
||||||
elif action.group('ATYPE') == ' checks':
|
elif action.group('ATYPE') == ' checks':
|
||||||
hand.addCheck( street, action.group('PNAME'))
|
hand.addCheck( street, action.group('PNAME'))
|
||||||
else:
|
else:
|
||||||
print "DEBUG: unimplemented readAction: %s %s" %(action.group('PNAME'),action.group('ATYPE'),)
|
logging.debug("Unimplemented readAction: %s %s" %(action.group('PNAME'),action.group('ATYPE'),))
|
||||||
|
|
||||||
|
|
||||||
def readShowdownActions(self, hand):
|
def readShowdownActions(self, hand):
|
||||||
"""Reads lines where holecards are reported in a showdown"""
|
"""Reads lines where holecards are reported in a showdown"""
|
||||||
for shows in self.re_ShowdownAction.finditer(hand.string):
|
logging.debug("readShowdownActions")
|
||||||
|
for shows in self.re_ShowdownAction.finditer(hand.handText):
|
||||||
cards = shows.group('CARDS')
|
cards = shows.group('CARDS')
|
||||||
cards = cards.split(', ')
|
cards = cards.split(', ')
|
||||||
|
logging.debug("readShowdownActions %s %s" %(cards, shows.group('PNAME')))
|
||||||
hand.addShownCards(cards, shows.group('PNAME'))
|
hand.addShownCards(cards, shows.group('PNAME'))
|
||||||
|
|
||||||
def readCollectPot(self,hand):
|
def readCollectPot(self,hand):
|
||||||
for m in self.re_CollectPot.finditer(hand.string):
|
for m in self.re_CollectPot.finditer(hand.handText):
|
||||||
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
||||||
|
|
||||||
def readShownCards(self,hand):
|
def readShownCards(self,hand):
|
||||||
"""Reads lines where hole & board cards are mixed to form a hand (summary lines)"""
|
"""Reads lines where hole & board cards are mixed to form a hand (summary lines)"""
|
||||||
for m in self.re_CollectPot.finditer(hand.string):
|
for m in self.re_CollectPot.finditer(hand.handText):
|
||||||
if m.group('CARDS') is not None:
|
if m.group('CARDS') is not None:
|
||||||
cards = m.group('CARDS')
|
cards = m.group('CARDS')
|
||||||
cards = cards.split(', ')
|
cards = cards.split(', ')
|
||||||
|
player = m.group('PNAME')
|
||||||
|
logging.debug("readShownCards %s cards=%s" % (player, cards))
|
||||||
hand.addShownCards(cards=None, player=m.group('PNAME'), holeandboard=cards)
|
hand.addShownCards(cards=None, player=m.group('PNAME'), holeandboard=cards)
|
||||||
|
|
||||||
|
|
||||||
|
@ -221,7 +228,7 @@ class Everleaf(HandHistoryConverter):
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
c = Configuration.Config()
|
c = Configuration.Config()
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
testfile = "regression-test-files/everleaf/Speed_Kuala_full.txt"
|
testfile = "regression-test-files/everleaf/plo/Naos.txt"
|
||||||
else:
|
else:
|
||||||
testfile = sys.argv[1]
|
testfile = sys.argv[1]
|
||||||
e = Everleaf(c, testfile)
|
e = Everleaf(c, testfile)
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import logging
|
||||||
import Configuration
|
import Configuration
|
||||||
from HandHistoryConverter import *
|
from HandHistoryConverter import *
|
||||||
|
|
||||||
|
@ -61,16 +62,17 @@ class FullTilt(HandHistoryConverter):
|
||||||
["ring", "omaha", "pl"]
|
["ring", "omaha", "pl"]
|
||||||
]
|
]
|
||||||
|
|
||||||
def determineGameType(self):
|
def determineGameType(self, handText):
|
||||||
# Cheating with this regex, only support nlhe at the moment
|
# Cheating with this regex, only support nlhe at the moment
|
||||||
# Full Tilt Poker Game #10777181585: Table Deerfly (deep 6) - $0.01/$0.02 - Pot Limit Omaha Hi - 2:24:44 ET - 2009/02/22
|
# Full Tilt Poker Game #10777181585: Table Deerfly (deep 6) - $0.01/$0.02 - Pot Limit Omaha Hi - 2:24:44 ET - 2009/02/22
|
||||||
# Full Tilt Poker Game #10773265574: Table Butte (6 max) - $0.01/$0.02 - Pot Limit Hold'em - 21:33:46 ET - 2009/02/21
|
# Full Tilt Poker Game #10773265574: Table Butte (6 max) - $0.01/$0.02 - Pot Limit Hold'em - 21:33:46 ET - 2009/02/21
|
||||||
# Full Tilt Poker Game #9403951181: Table CR - tay - $0.05/$0.10 - No Limit Hold'em - 9:40:20 ET - 2008/12/09
|
# Full Tilt Poker Game #9403951181: Table CR - tay - $0.05/$0.10 - No Limit Hold'em - 9:40:20 ET - 2008/12/09
|
||||||
|
# Full Tilt Poker Game #10809877615: Table Danville - $0.50/$1 Ante $0.10 - Limit Razz - 21:47:27 ET - 2009/02/23
|
||||||
structure = "" # nl, pl, cn, cp, fl
|
structure = "" # nl, pl, cn, cp, fl
|
||||||
game = ""
|
game = ""
|
||||||
|
|
||||||
|
|
||||||
m = self.re_GameInfo.search(self.obs)
|
m = self.re_GameInfo.search(handText)
|
||||||
if m.group('LTYPE') == "No ":
|
if m.group('LTYPE') == "No ":
|
||||||
structure = "nl"
|
structure = "nl"
|
||||||
elif m.group('LTYPE') == "Pot ":
|
elif m.group('LTYPE') == "Pot ":
|
||||||
|
@ -85,14 +87,14 @@ class FullTilt(HandHistoryConverter):
|
||||||
elif m.group('GAME') == "Razz":
|
elif m.group('GAME') == "Razz":
|
||||||
game = "razz"
|
game = "razz"
|
||||||
|
|
||||||
print m.groups()
|
logging.debug("HandInfo: %s", m.groupdict())
|
||||||
|
|
||||||
gametype = ["ring", game, structure, m.group('SB'), m.group('BB')]
|
gametype = ["ring", game, structure, m.group('SB'), m.group('BB')]
|
||||||
|
|
||||||
return gametype
|
return gametype
|
||||||
|
|
||||||
def readHandInfo(self, hand):
|
def readHandInfo(self, hand):
|
||||||
m = self.re_HandInfo.search(hand.string,re.DOTALL)
|
m = self.re_HandInfo.search(hand.handText,re.DOTALL)
|
||||||
#print m.groups()
|
#print m.groups()
|
||||||
hand.handid = m.group('HID')
|
hand.handid = m.group('HID')
|
||||||
hand.tablename = m.group('TABLE')
|
hand.tablename = m.group('TABLE')
|
||||||
|
@ -113,7 +115,7 @@ class FullTilt(HandHistoryConverter):
|
||||||
#FIXME: hand.buttonpos = int(m.group('BUTTON'))
|
#FIXME: hand.buttonpos = int(m.group('BUTTON'))
|
||||||
|
|
||||||
def readPlayerStacks(self, hand):
|
def readPlayerStacks(self, hand):
|
||||||
m = self.re_PlayerInfo.finditer(hand.string)
|
m = self.re_PlayerInfo.finditer(hand.handText)
|
||||||
players = []
|
players = []
|
||||||
for a in m:
|
for a in m:
|
||||||
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
|
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
|
||||||
|
@ -126,14 +128,14 @@ class FullTilt(HandHistoryConverter):
|
||||||
m = re.search(r"\*\*\* HOLE CARDS \*\*\*(?P<PREFLOP>.+(?=\*\*\* FLOP \*\*\*)|.+)"
|
m = re.search(r"\*\*\* HOLE CARDS \*\*\*(?P<PREFLOP>.+(?=\*\*\* FLOP \*\*\*)|.+)"
|
||||||
r"(\*\*\* FLOP \*\*\*(?P<FLOP> \[\S\S \S\S \S\S\].+(?=\*\*\* TURN \*\*\*)|.+))?"
|
r"(\*\*\* FLOP \*\*\*(?P<FLOP> \[\S\S \S\S \S\S\].+(?=\*\*\* TURN \*\*\*)|.+))?"
|
||||||
r"(\*\*\* TURN \*\*\* \[\S\S \S\S \S\S] (?P<TURN>\[\S\S\].+(?=\*\*\* RIVER \*\*\*)|.+))?"
|
r"(\*\*\* TURN \*\*\* \[\S\S \S\S \S\S] (?P<TURN>\[\S\S\].+(?=\*\*\* RIVER \*\*\*)|.+))?"
|
||||||
r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P<RIVER>\[\S\S\].+))?", hand.string,re.DOTALL)
|
r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P<RIVER>\[\S\S\].+))?", hand.handText,re.DOTALL)
|
||||||
elif self.gametype[1] == "razz":
|
elif self.gametype[1] == "razz":
|
||||||
m = re.search(r"(?P<ANTES>.+(?=\*\*\* 3RD STREET \*\*\*)|.+)"
|
m = re.search(r"(?P<ANTES>.+(?=\*\*\* 3RD STREET \*\*\*)|.+)"
|
||||||
r"(\*\*\* 3RD STREET \*\*\*(?P<THIRD>.+(?=\*\*\* 4TH STREET \*\*\*)|.+))?"
|
r"(\*\*\* 3RD STREET \*\*\*(?P<THIRD>.+(?=\*\*\* 4TH STREET \*\*\*)|.+))?"
|
||||||
r"(\*\*\* 4TH STREET \*\*\*(?P<FOURTH>.+(?=\*\*\* 5TH STREET \*\*\*)|.+))?"
|
r"(\*\*\* 4TH STREET \*\*\*(?P<FOURTH>.+(?=\*\*\* 5TH STREET \*\*\*)|.+))?"
|
||||||
r"(\*\*\* 5TH STREET \*\*\*(?P<FIFTH>.+(?=\*\*\* 6TH STREET \*\*\*)|.+))?"
|
r"(\*\*\* 5TH STREET \*\*\*(?P<FIFTH>.+(?=\*\*\* 6TH STREET \*\*\*)|.+))?"
|
||||||
r"(\*\*\* 6TH STREET \*\*\*(?P<SIXTH>.+(?=\*\*\* 7TH STREET \*\*\*)|.+))?"
|
r"(\*\*\* 6TH STREET \*\*\*(?P<SIXTH>.+(?=\*\*\* 7TH STREET \*\*\*)|.+))?"
|
||||||
r"(\*\*\* 7TH STREET \*\*\*(?P<SEVENTH>.+))?", hand.string,re.DOTALL)
|
r"(\*\*\* 7TH STREET \*\*\*(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
|
||||||
hand.addStreets(m)
|
hand.addStreets(m)
|
||||||
|
|
||||||
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
||||||
|
@ -145,34 +147,32 @@ class FullTilt(HandHistoryConverter):
|
||||||
|
|
||||||
def readBlinds(self, hand):
|
def readBlinds(self, hand):
|
||||||
try:
|
try:
|
||||||
m = self.re_PostSB.search(hand.string)
|
m = self.re_PostSB.search(hand.handText)
|
||||||
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
||||||
except: # no small blind
|
except: # no small blind
|
||||||
hand.addBlind(None, None, None)
|
hand.addBlind(None, None, None)
|
||||||
for a in self.re_PostBB.finditer(hand.string):
|
for a in self.re_PostBB.finditer(hand.handText):
|
||||||
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
||||||
for a in self.re_PostBoth.finditer(hand.string):
|
for a in self.re_PostBoth.finditer(hand.handText):
|
||||||
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
|
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
|
||||||
|
|
||||||
def readAntes(self, hand):
|
def readAntes(self, hand):
|
||||||
print "DEBUG: reading antes"
|
logging.debug("reading antes")
|
||||||
m = self.re_Antes.finditer(hand.string)
|
m = self.re_Antes.finditer(hand.handText)
|
||||||
for player in m:
|
for player in m:
|
||||||
print "DEBUG: hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE'))
|
logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
|
||||||
hand.addAnte(player.group('PNAME'), player.group('ANTE'))
|
hand.addAnte(player.group('PNAME'), player.group('ANTE'))
|
||||||
|
|
||||||
def readBringIn(self, hand):
|
def readBringIn(self, hand):
|
||||||
print "DEBUG: reading bring in"
|
m = self.re_BringIn.search(hand.handText,re.DOTALL)
|
||||||
# print hand.string
|
logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
|
||||||
m = self.re_BringIn.search(hand.string,re.DOTALL)
|
|
||||||
print "DEBUG: Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN'))
|
|
||||||
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
||||||
|
|
||||||
def readButton(self, hand):
|
def readButton(self, hand):
|
||||||
hand.buttonpos = int(self.re_Button.search(hand.string).group('BUTTON'))
|
hand.buttonpos = int(self.re_Button.search(hand.handText).group('BUTTON'))
|
||||||
|
|
||||||
def readHeroCards(self, hand):
|
def readHeroCards(self, hand):
|
||||||
m = self.re_HeroCards.search(hand.string)
|
m = self.re_HeroCards.search(hand.handText)
|
||||||
if(m == None):
|
if(m == None):
|
||||||
#Not involved in hand
|
#Not involved in hand
|
||||||
hand.involved = False
|
hand.involved = False
|
||||||
|
@ -181,7 +181,7 @@ class FullTilt(HandHistoryConverter):
|
||||||
# "2c, qh" -> set(["2c","qc"])
|
# "2c, qh" -> set(["2c","qc"])
|
||||||
# Also works with Omaha hands.
|
# Also works with Omaha hands.
|
||||||
cards = m.group('CARDS')
|
cards = m.group('CARDS')
|
||||||
cards = set(cards.split(' '))
|
cards = cards.split(' ')
|
||||||
hand.addHoleCards(cards, m.group('PNAME'))
|
hand.addHoleCards(cards, m.group('PNAME'))
|
||||||
|
|
||||||
def readPlayerCards(self, hand, street):
|
def readPlayerCards(self, hand, street):
|
||||||
|
@ -190,12 +190,12 @@ class FullTilt(HandHistoryConverter):
|
||||||
print "DEBUG: razz/stud readPlayerCards"
|
print "DEBUG: razz/stud readPlayerCards"
|
||||||
print hand.streets.group(street)
|
print hand.streets.group(street)
|
||||||
for player in m:
|
for player in m:
|
||||||
print player.groups()
|
logging.debug(player.groupdict())
|
||||||
cards = player.group('CARDS')
|
cards = player.group('CARDS')
|
||||||
if player.group('NEWCARD') != None:
|
if player.group('NEWCARD') != None:
|
||||||
print cards
|
print cards
|
||||||
cards = cards + " " + player.group('NEWCARD')
|
cards = cards + " " + player.group('NEWCARD')
|
||||||
cards = set(cards.split(' '))
|
cards = cards.split(' ')
|
||||||
hand.addPlayerCards(cards, player.group('PNAME'))
|
hand.addPlayerCards(cards, player.group('PNAME'))
|
||||||
|
|
||||||
def readAction(self, hand, street):
|
def readAction(self, hand, street):
|
||||||
|
@ -216,20 +216,20 @@ class FullTilt(HandHistoryConverter):
|
||||||
|
|
||||||
|
|
||||||
def readShowdownActions(self, hand):
|
def readShowdownActions(self, hand):
|
||||||
for shows in self.re_ShowdownAction.finditer(hand.string):
|
for shows in self.re_ShowdownAction.finditer(hand.handText):
|
||||||
cards = shows.group('CARDS')
|
cards = shows.group('CARDS')
|
||||||
cards = set(cards.split(' '))
|
cards = cards.split(' ')
|
||||||
hand.addShownCards(cards, shows.group('PNAME'))
|
hand.addShownCards(cards, shows.group('PNAME'))
|
||||||
|
|
||||||
def readCollectPot(self,hand):
|
def readCollectPot(self,hand):
|
||||||
for m in self.re_CollectPot.finditer(hand.string):
|
for m in self.re_CollectPot.finditer(hand.handText):
|
||||||
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
||||||
|
|
||||||
def readShownCards(self,hand):
|
def readShownCards(self,hand):
|
||||||
for m in self.re_ShownCards.finditer(hand.string):
|
for m in self.re_ShownCards.finditer(hand.handText):
|
||||||
if m.group('CARDS') is not None:
|
if m.group('CARDS') is not None:
|
||||||
cards = m.group('CARDS')
|
cards = m.group('CARDS')
|
||||||
cards = set(cards.split(' '))
|
cards = cards.split(' ')
|
||||||
hand.addShownCards(cards=cards, player=m.group('PNAME'))
|
hand.addShownCards(cards=cards, player=m.group('PNAME'))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class GuiBulkImport():
|
||||||
starttime = time()
|
starttime = time()
|
||||||
if not self.importer.settings['threads'] > 1:
|
if not self.importer.settings['threads'] > 1:
|
||||||
(stored, dups, partial, errs, ttime) = self.importer.runImport()
|
(stored, dups, partial, errs, ttime) = self.importer.runImport()
|
||||||
print 'GuiBulkImport.import_dir done: Stored: %d Duplicates: %d Partial: %d Errors: %d in %s seconds - %d/sec'\
|
print 'GuiBulkImport.import_dir done: Stored: %d \tDuplicates: %d \tPartial: %d \tErrors: %d in %s seconds - %d/sec'\
|
||||||
% (stored, dups, partial, errs, ttime, stored / ttime)
|
% (stored, dups, partial, errs, ttime, stored / ttime)
|
||||||
else:
|
else:
|
||||||
self.importer.RunImportThreaded()
|
self.importer.RunImportThreaded()
|
||||||
|
@ -73,7 +73,7 @@ class GuiBulkImport():
|
||||||
self.importer.setCallHud(False)
|
self.importer.setCallHud(False)
|
||||||
starttime = time()
|
starttime = time()
|
||||||
(stored, dups, partial, errs, ttime) = self.importer.runImport()
|
(stored, dups, partial, errs, ttime) = self.importer.runImport()
|
||||||
print 'GuiBulkImport.import_dir done: Stored: %d Duplicates: %d Partial: %d Errors: %d in %s seconds - %d/sec'\
|
print 'GuiBulkImport.import_dir done: Stored: %d \tDuplicates: %d \tPartial: %d \tErrors: %d in %s seconds - %d/sec'\
|
||||||
% (stored, dups, partial, errs, ttime, stored / ttime)
|
% (stored, dups, partial, errs, ttime, stored / ttime)
|
||||||
self.importer.clearFileList()
|
self.importer.clearFileList()
|
||||||
|
|
||||||
|
|
178
pyfpdb/GuiPositionalStats.py
Normal file
178
pyfpdb/GuiPositionalStats.py
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
#Copyright 2008 Steffen Jobbagy-Felso
|
||||||
|
#This program is free software: you can redistribute it and/or modify
|
||||||
|
#it under the terms of the GNU Affero General Public License as published by
|
||||||
|
#the Free Software Foundation, version 3 of the License.
|
||||||
|
#
|
||||||
|
#This program is distributed in the hope that it will be useful,
|
||||||
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
#GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
#You should have received a copy of the GNU Affero General Public License
|
||||||
|
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#In the "official" distribution you can find the license in
|
||||||
|
#agpl-3.0.txt in the docs folder of the package.
|
||||||
|
|
||||||
|
import threading
|
||||||
|
import pygtk
|
||||||
|
pygtk.require('2.0')
|
||||||
|
import gtk
|
||||||
|
import os
|
||||||
|
|
||||||
|
import fpdb_import
|
||||||
|
import fpdb_db
|
||||||
|
import FpdbSQLQueries
|
||||||
|
|
||||||
|
class GuiPositionalStats (threading.Thread):
|
||||||
|
def get_vbox(self):
|
||||||
|
"""returns the vbox of this thread"""
|
||||||
|
return self.main_hbox
|
||||||
|
|
||||||
|
def toggleCallback(self, widget, data=None):
|
||||||
|
# print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
|
||||||
|
self.activesite = data
|
||||||
|
print "DEBUG: activesite set to %s" %(self.activesite)
|
||||||
|
|
||||||
|
def refreshStats(self, widget, data):
|
||||||
|
try: self.stats_table.destroy()
|
||||||
|
except AttributeError: pass
|
||||||
|
self.fillStatsFrame(self.stats_frame)
|
||||||
|
|
||||||
|
def fillStatsFrame(self, vbox):
|
||||||
|
# Get currently active site and grab playerid
|
||||||
|
print "DEBUG: attempting to fill stats frame"
|
||||||
|
tmp = self.sql.query['playerStatsByPosition']
|
||||||
|
|
||||||
|
result = self.cursor.execute(self.sql.query['getPlayerId'], (self.heroes[self.activesite],))
|
||||||
|
result = self.cursor.fetchall()
|
||||||
|
if not result == ():
|
||||||
|
pid = result[0][0]
|
||||||
|
pid = result[0][0]
|
||||||
|
tmp = tmp.replace("<player_test>", "(" + str(pid) + ")")
|
||||||
|
self.cursor.execute(tmp)
|
||||||
|
result = self.cursor.fetchall()
|
||||||
|
cols = 16
|
||||||
|
rows = len(result)+1 # +1 for title row
|
||||||
|
self.stats_table = gtk.Table(rows, cols, False)
|
||||||
|
self.stats_table.set_col_spacings(4)
|
||||||
|
self.stats_table.show()
|
||||||
|
vbox.add(self.stats_table)
|
||||||
|
|
||||||
|
# Create header row
|
||||||
|
titles = ("Game", "Position", "#", "VPIP", "PFR", "Saw_F", "SawSD", "WtSDwsF", "W$SD", "FlAFq", "TuAFq", "RvAFq", "PoFAFq", "Net($)", "BB/100", "$/hand", "Variance")
|
||||||
|
|
||||||
|
col = 0
|
||||||
|
row = 0
|
||||||
|
for t in titles:
|
||||||
|
l = gtk.Label(titles[col])
|
||||||
|
l.show()
|
||||||
|
self.stats_table.attach(l, col, col+1, row, row+1, yoptions=gtk.SHRINK)
|
||||||
|
col +=1
|
||||||
|
|
||||||
|
for row in range(rows-1):
|
||||||
|
if(row%2 == 0):
|
||||||
|
bgcolor = "white"
|
||||||
|
else:
|
||||||
|
bgcolor = "lightgrey"
|
||||||
|
for col in range(cols):
|
||||||
|
eb = gtk.EventBox()
|
||||||
|
eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
|
||||||
|
if result[row][col]:
|
||||||
|
l = gtk.Label(result[row][col])
|
||||||
|
else:
|
||||||
|
l = gtk.Label(' ')
|
||||||
|
if col == 0:
|
||||||
|
l.set_alignment(xalign=0.0, yalign=0.5)
|
||||||
|
else:
|
||||||
|
l.set_alignment(xalign=1.0, yalign=0.5)
|
||||||
|
eb.add(l)
|
||||||
|
self.stats_table.attach(eb, col, col+1, row+1, row+2, yoptions=gtk.SHRINK)
|
||||||
|
l.show()
|
||||||
|
eb.show()
|
||||||
|
self.fdb.db.commit()
|
||||||
|
#end def fillStatsFrame(self, vbox):
|
||||||
|
|
||||||
|
def fillPlayerFrame(self, vbox):
|
||||||
|
for site in self.conf.supported_sites.keys():
|
||||||
|
hbox = gtk.HBox(False, 0)
|
||||||
|
vbox.pack_start(hbox, False, True, 0)
|
||||||
|
hbox.show()
|
||||||
|
|
||||||
|
player = self.conf.supported_sites[site].screen_name
|
||||||
|
self.createPlayerLine(hbox, site, player)
|
||||||
|
hbox = gtk.HBox(False, 0)
|
||||||
|
button = gtk.Button("Refresh")
|
||||||
|
button.connect("clicked", self.refreshStats, False)
|
||||||
|
button.show()
|
||||||
|
hbox.add(button)
|
||||||
|
vbox.pack_start(hbox, False, True, 0)
|
||||||
|
hbox.show()
|
||||||
|
|
||||||
|
def createPlayerLine(self, hbox, site, player):
|
||||||
|
if(self.buttongroup == None):
|
||||||
|
button = gtk.RadioButton(None, site + " id:")
|
||||||
|
button.set_active(True)
|
||||||
|
self.buttongroup = button
|
||||||
|
self.activesite = site
|
||||||
|
else:
|
||||||
|
button = gtk.RadioButton(self.buttongroup, site + " id:")
|
||||||
|
hbox.pack_start(button, True, True, 0)
|
||||||
|
button.connect("toggled", self.toggleCallback, site)
|
||||||
|
button.show()
|
||||||
|
|
||||||
|
pname = gtk.Entry()
|
||||||
|
pname.set_text(player)
|
||||||
|
pname.set_width_chars(20)
|
||||||
|
hbox.pack_start(pname, False, True, 0)
|
||||||
|
pname.connect("changed", self.__set_hero_name, site)
|
||||||
|
#TODO: Look at GtkCompletion - to fill out usernames
|
||||||
|
pname.show()
|
||||||
|
self.__set_hero_name(pname, site)
|
||||||
|
|
||||||
|
def __set_hero_name(self, w, site):
|
||||||
|
self.heroes[site] = w.get_text()
|
||||||
|
|
||||||
|
def __init__(self, db, config, querylist, debug=True):
|
||||||
|
self.debug=debug
|
||||||
|
self.conf=config
|
||||||
|
|
||||||
|
# create new db connection to avoid conflicts with other threads
|
||||||
|
self.fdb = fpdb_db.fpdb_db()
|
||||||
|
self.fdb.do_connect(self.conf)
|
||||||
|
self.cursor=self.fdb.cursor
|
||||||
|
|
||||||
|
self.sql = querylist
|
||||||
|
|
||||||
|
self.activesite = None
|
||||||
|
self.buttongroup = None
|
||||||
|
|
||||||
|
self.heroes = {}
|
||||||
|
self.stat_table = None
|
||||||
|
self.stats_frame = None
|
||||||
|
|
||||||
|
self.main_hbox = gtk.HBox(False, 0)
|
||||||
|
self.main_hbox.show()
|
||||||
|
|
||||||
|
playerFrame = gtk.Frame("Hero:")
|
||||||
|
playerFrame.set_label_align(0.0, 0.0)
|
||||||
|
playerFrame.show()
|
||||||
|
vbox = gtk.VBox(False, 0)
|
||||||
|
vbox.show()
|
||||||
|
|
||||||
|
self.fillPlayerFrame(vbox)
|
||||||
|
playerFrame.add(vbox)
|
||||||
|
|
||||||
|
statsFrame = gtk.Frame("Stats:")
|
||||||
|
statsFrame.set_label_align(0.0, 0.0)
|
||||||
|
statsFrame.show()
|
||||||
|
self.stats_frame = gtk.VBox(False, 0)
|
||||||
|
self.stats_frame.show()
|
||||||
|
|
||||||
|
self.fillStatsFrame(self.stats_frame)
|
||||||
|
statsFrame.add(self.stats_frame)
|
||||||
|
|
||||||
|
self.main_hbox.pack_start(playerFrame)
|
||||||
|
self.main_hbox.pack_start(statsFrame)
|
||||||
|
|
|
@ -83,6 +83,7 @@ class HUD_main(object):
|
||||||
self.hud_dict[table].main_window.destroy()
|
self.hud_dict[table].main_window.destroy()
|
||||||
self.vb.remove(self.hud_dict[table].tablehudlabel)
|
self.vb.remove(self.hud_dict[table].tablehudlabel)
|
||||||
del(self.hud_dict[table])
|
del(self.hud_dict[table])
|
||||||
|
self.main_window.resize(1,1)
|
||||||
|
|
||||||
def create_HUD(self, new_hand_id, table, table_name, max, poker_game, is_tournament, stat_dict, cards):
|
def create_HUD(self, new_hand_id, table, table_name, max, poker_game, is_tournament, stat_dict, cards):
|
||||||
|
|
||||||
|
@ -93,6 +94,7 @@ class HUD_main(object):
|
||||||
newlabel = gtk.Label(table.site + " - " + table_name)
|
newlabel = gtk.Label(table.site + " - " + table_name)
|
||||||
self.vb.add(newlabel)
|
self.vb.add(newlabel)
|
||||||
newlabel.show()
|
newlabel.show()
|
||||||
|
self.main_window.resize_children()
|
||||||
|
|
||||||
self.hud_dict[table_name].tablehudlabel = newlabel
|
self.hud_dict[table_name].tablehudlabel = newlabel
|
||||||
self.hud_dict[table_name].create(new_hand_id, self.config, stat_dict, cards)
|
self.hud_dict[table_name].create(new_hand_id, self.config, stat_dict, cards)
|
||||||
|
|
|
@ -21,6 +21,7 @@ import Hand
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
|
@ -34,12 +35,12 @@ class Hand:
|
||||||
# def __init__(self, sitename, gametype, sb, bb, string):
|
# def __init__(self, sitename, gametype, sb, bb, string):
|
||||||
|
|
||||||
UPS = {'a':'A', 't':'T', 'j':'J', 'q':'Q', 'k':'K', 'S':'s', 'C':'c', 'H':'h', 'D':'d'}
|
UPS = {'a':'A', 't':'T', 'j':'J', 'q':'Q', 'k':'K', 'S':'s', 'C':'c', 'H':'h', 'D':'d'}
|
||||||
def __init__(self, sitename, gametype, string):
|
def __init__(self, sitename, gametype, handText):
|
||||||
self.sitename = sitename
|
self.sitename = sitename
|
||||||
self.gametype = gametype
|
self.gametype = gametype
|
||||||
self.string = string
|
self.handText = handText
|
||||||
|
|
||||||
if gametype[1] == "hold" or self.gametype[1] == "omaha":
|
if gametype[1] == "hold" or self.gametype[1] == "omahahi":
|
||||||
self.streetList = ['PREFLOP','FLOP','TURN','RIVER'] # a list of the observed street names in order
|
self.streetList = ['PREFLOP','FLOP','TURN','RIVER'] # a list of the observed street names in order
|
||||||
elif self.gametype[1] == "razz" or self.gametype[1] == "stud" or self.gametype[1] == "stud8":
|
elif self.gametype[1] == "razz" or self.gametype[1] == "stud" or self.gametype[1] == "stud8":
|
||||||
self.streetList = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH'] # a list of the observed street names in order
|
self.streetList = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH'] # a list of the observed street names in order
|
||||||
|
@ -123,14 +124,13 @@ If a player has None chips he won't be added."""
|
||||||
|
|
||||||
def addStreets(self, match):
|
def addStreets(self, match):
|
||||||
# go through m and initialise actions to empty list for each street.
|
# go through m and initialise actions to empty list for each street.
|
||||||
if match is not None:
|
if match:
|
||||||
self.streets = match
|
self.streets = match
|
||||||
for street in match.groupdict():
|
for street in match.groupdict():
|
||||||
if match.group(street) is not None:
|
if match.group(street) is not None:
|
||||||
self.actions[street] = []
|
self.actions[street] = []
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print "empty markStreets match" # better to raise exception and put process hand in a try block
|
logging.error("markstreets didn't match")
|
||||||
|
|
||||||
def addHoleCards(self, cards, player):
|
def addHoleCards(self, cards, player):
|
||||||
"""\
|
"""\
|
||||||
|
@ -193,6 +193,7 @@ Card ranks will be uppercased
|
||||||
print "[ERROR] discardHoleCard tried to discard a card %s didn't have" % (player,)
|
print "[ERROR] discardHoleCard tried to discard a card %s didn't have" % (player,)
|
||||||
|
|
||||||
def setCommunityCards(self, street, cards):
|
def setCommunityCards(self, street, cards):
|
||||||
|
logging.debug("setCommunityCards %s %s" %(street, cards))
|
||||||
self.board[street] = [self.card(c) for c in cards]
|
self.board[street] = [self.card(c) for c in cards]
|
||||||
|
|
||||||
def card(self,c):
|
def card(self,c):
|
||||||
|
@ -216,12 +217,12 @@ Card ranks will be uppercased
|
||||||
# Player in small blind posts
|
# Player in small blind posts
|
||||||
# - this is a bet of 1 sb, as yet uncalled.
|
# - this is a bet of 1 sb, as yet uncalled.
|
||||||
# Player in the big blind posts
|
# Player in the big blind posts
|
||||||
# - this is a bet of 1 bb and is the new uncalled
|
# - this is a call of 1 bb and is the new uncalled
|
||||||
#
|
#
|
||||||
# If a player posts a big & small blind
|
# If a player posts a big & small blind
|
||||||
# - FIXME: We dont record this for later printing yet
|
# - FIXME: We dont record this for later printing yet
|
||||||
|
|
||||||
#print "DEBUG addBlind: %s posts %s, %s" % (player, blindtype, amount)
|
logging.debug("addBlind: %s posts %s, %s" % (player, blindtype, amount))
|
||||||
if player is not None:
|
if player is not None:
|
||||||
self.bets['PREFLOP'][player].append(Decimal(amount))
|
self.bets['PREFLOP'][player].append(Decimal(amount))
|
||||||
self.stacks[player] -= Decimal(amount)
|
self.stacks[player] -= Decimal(amount)
|
||||||
|
@ -397,13 +398,31 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
||||||
"cp" : "Cap Pot Limit"
|
"cp" : "Cap Pot Limit"
|
||||||
}
|
}
|
||||||
|
|
||||||
print "DEBUG: self.gametype: %s" %(self.gametype)
|
logging.debug("gametype: %s" %(self.gametype))
|
||||||
string = "%s %s" %(gs[self.gametype[1]], ls[self.gametype[2]])
|
retstring = "%s %s" %(gs[self.gametype[1]], ls[self.gametype[2]])
|
||||||
|
|
||||||
|
return retstring
|
||||||
|
|
||||||
|
def lookupLimitBetSize(self):
|
||||||
|
#Lookup table for limit games
|
||||||
|
betlist = {
|
||||||
|
"Everleaf" : { "0.10" : ("0.02", "0.05"),
|
||||||
|
"0.20" : ("0.05", "0.10"),
|
||||||
|
"0.50" : ("0.10", "0.25"),
|
||||||
|
"1.00" : ("0.25", "0.50")
|
||||||
|
},
|
||||||
|
"FullTilt" : { "0.10" : ("0.02", "0.05"),
|
||||||
|
"0.20" : ("0.05", "0.10"),
|
||||||
|
"1" : ("0.25", "0.50"),
|
||||||
|
"2" : ("0.50", "1"),
|
||||||
|
"4" : ("1", "2")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return betlist[self.sitename][self.bb]
|
||||||
|
|
||||||
return string
|
|
||||||
|
|
||||||
def writeHand(self, fh=sys.__stdout__):
|
def writeHand(self, fh=sys.__stdout__):
|
||||||
if self.gametype[1] == "hold" or self.gametype[1] == "omaha":
|
if self.gametype[1] == "hold" or self.gametype[1] == "omahahi":
|
||||||
self.writeHoldemHand(fh)
|
self.writeHoldemHand(fh)
|
||||||
else:
|
else:
|
||||||
self.writeStudHand(fh)
|
self.writeStudHand(fh)
|
||||||
|
@ -424,13 +443,19 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
||||||
|
|
||||||
|
|
||||||
#May be more than 1 bb posting
|
#May be more than 1 bb posting
|
||||||
|
if self.gametype[2] == "fl":
|
||||||
|
(smallbet, bigbet) = self.lookupLimitBetSize()
|
||||||
|
else:
|
||||||
|
smallbet = self.sb
|
||||||
|
bigbet = self.bb
|
||||||
|
|
||||||
for a in self.posted:
|
for a in self.posted:
|
||||||
if(a[1] == "small blind"):
|
if(a[1] == "small blind"):
|
||||||
print >>fh, _("%s: posts small blind $%s" %(a[0], self.sb))
|
print >>fh, _("%s: posts small blind $%s" %(a[0], smallbet))
|
||||||
if(a[1] == "big blind"):
|
if(a[1] == "big blind"):
|
||||||
print >>fh, _("%s: posts big blind $%s" %(a[0], self.bb))
|
print >>fh, _("%s: posts big blind $%s" %(a[0], bigbet))
|
||||||
if(a[1] == "both"):
|
if(a[1] == "both"):
|
||||||
print >>fh, _("%s: posts small & big blinds $%.2f" %(a[0], (Decimal(self.sb) + Decimal(self.bb))))
|
print >>fh, _("%s: posts small & big blinds $%.2f" %(a[0], (Decimal(smallbet) + Decimal(bigbet))))
|
||||||
|
|
||||||
print >>fh, _("*** HOLE CARDS ***")
|
print >>fh, _("*** HOLE CARDS ***")
|
||||||
if self.involved:
|
if self.involved:
|
||||||
|
@ -565,7 +590,7 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
||||||
# we probably don't need a showdown section in pseudo stars format for our filtering purposes
|
# we probably don't need a showdown section in pseudo stars format for our filtering purposes
|
||||||
if 'SHOWDOWN' in self.actions:
|
if 'SHOWDOWN' in self.actions:
|
||||||
print >>fh, _("*** SHOW DOWN ***")
|
print >>fh, _("*** SHOW DOWN ***")
|
||||||
# print >>fh, "DEBUG: what do they show"
|
# TODO: print showdown lines.
|
||||||
|
|
||||||
# Current PS format has the lines:
|
# Current PS format has the lines:
|
||||||
# Uncalled bet ($111.25) returned to s0rrow
|
# Uncalled bet ($111.25) returned to s0rrow
|
||||||
|
@ -749,4 +774,3 @@ class Pot(object):
|
||||||
return _("too many pots.. no small blind and walk in bb?. self.pots: %s" %(self.pots))
|
return _("too many pots.. no small blind and walk in bb?. self.pots: %s" %(self.pots))
|
||||||
# I don't know stars format for a walk in the bb when sb doesn't post.
|
# I don't know stars format for a walk in the bb when sb doesn't post.
|
||||||
# The thing to do here is raise a Hand error like fpdb import does and file it into errors.txt
|
# The thing to do here is raise a Hand error like fpdb import does and file it into errors.txt
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import Hand
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
|
@ -74,9 +75,9 @@ gettext.install('myapplication')
|
||||||
|
|
||||||
|
|
||||||
class HandHistoryConverter:
|
class HandHistoryConverter:
|
||||||
# eval = PokerEval()
|
|
||||||
def __init__(self, config, file, sitename):
|
def __init__(self, config, file, sitename):
|
||||||
print "HandHistory init called"
|
logging.info("HandHistory init called")
|
||||||
self.c = config
|
self.c = config
|
||||||
self.sitename = sitename
|
self.sitename = sitename
|
||||||
self.obs = "" # One big string
|
self.obs = "" # One big string
|
||||||
|
@ -124,7 +125,7 @@ class HandHistoryConverter:
|
||||||
self.hands = self.splitFileIntoHands()
|
self.hands = self.splitFileIntoHands()
|
||||||
outfile = open(self.ofile, 'w')
|
outfile = open(self.ofile, 'w')
|
||||||
for hand in self.hands:
|
for hand in self.hands:
|
||||||
#print "\nDEBUG: Input:\n"+hand.string
|
#print "\nDEBUG: Input:\n"+hand.handText
|
||||||
self.readHandInfo(hand)
|
self.readHandInfo(hand)
|
||||||
|
|
||||||
self.readPlayerStacks(hand)
|
self.readPlayerStacks(hand)
|
||||||
|
@ -141,7 +142,7 @@ class HandHistoryConverter:
|
||||||
|
|
||||||
self.markStreets(hand)
|
self.markStreets(hand)
|
||||||
# Different calls if stud or holdem like
|
# Different calls if stud or holdem like
|
||||||
if self.gametype[1] == "hold" or self.gametype[1] == "omaha":
|
if self.gametype[1] == "hold" or self.gametype[1] == "omahahi":
|
||||||
self.readBlinds(hand)
|
self.readBlinds(hand)
|
||||||
self.readButton(hand)
|
self.readButton(hand)
|
||||||
self.readHeroCards(hand) # want to generalise to draw games
|
self.readHeroCards(hand) # want to generalise to draw games
|
||||||
|
@ -155,7 +156,7 @@ class HandHistoryConverter:
|
||||||
for street in hand.streetList: # go through them in order
|
for street in hand.streetList: # go through them in order
|
||||||
print "DEBUG: ", street
|
print "DEBUG: ", street
|
||||||
if hand.streets.group(street) is not None:
|
if hand.streets.group(street) is not None:
|
||||||
if self.gametype[1] == "hold" or self.gametype[1] == "omaha":
|
if self.gametype[1] == "hold" or self.gametype[1] == "omahahi":
|
||||||
self.readCommunityCards(hand, street) # read community cards
|
self.readCommunityCards(hand, street) # read community cards
|
||||||
elif self.gametype[1] == "razz" or self.gametype[1] == "stud" or self.gametype[1] == "stud8":
|
elif self.gametype[1] == "razz" or self.gametype[1] == "stud" or self.gametype[1] == "stud8":
|
||||||
self.readPlayerCards(hand, street)
|
self.readPlayerCards(hand, street)
|
||||||
|
|
|
@ -30,6 +30,7 @@ import fpdb_db
|
||||||
import fpdb_import
|
import fpdb_import
|
||||||
import fpdb_simple
|
import fpdb_simple
|
||||||
import FpdbSQLQueries
|
import FpdbSQLQueries
|
||||||
|
import EverleafToFpdb
|
||||||
import Tables
|
import Tables
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -52,6 +53,8 @@ class TestSequenceFunctions(unittest.TestCase):
|
||||||
self.mysqlimporter = fpdb_import.Importer(self, self.mysql_settings, self.c)
|
self.mysqlimporter = fpdb_import.Importer(self, self.mysql_settings, self.c)
|
||||||
self.mysqlimporter.setCallHud(False)
|
self.mysqlimporter.setCallHud(False)
|
||||||
|
|
||||||
|
self.everleaf = EverleafToFpdb.Everleaf(self.c, "Nofile")
|
||||||
|
|
||||||
# """Configure Postgres settings/database and establish connection"""
|
# """Configure Postgres settings/database and establish connection"""
|
||||||
# self.pg_settings={ 'db-host':"localhost", 'db-backend':3, 'db-databaseName':"fpdbtest", 'db-user':"fpdb", 'db-password':"fpdb"}
|
# self.pg_settings={ 'db-host':"localhost", 'db-backend':3, 'db-databaseName':"fpdbtest", 'db-user':"fpdb", 'db-password':"fpdb"}
|
||||||
# self.pg_db = fpdb_db.fpdb_db()
|
# self.pg_db = fpdb_db.fpdb_db()
|
||||||
|
@ -110,12 +113,57 @@ class TestSequenceFunctions(unittest.TestCase):
|
||||||
self.failUnless(result == "French", "French (deep) parsed incorrectly. Expected 'French' got: " + str(result))
|
self.failUnless(result == "French", "French (deep) parsed incorrectly. Expected 'French' got: " + str(result))
|
||||||
# result = ("French (deep) - $0.25/$0.50 - No Limit Hold'em - Logged In As xxxx")
|
# result = ("French (deep) - $0.25/$0.50 - No Limit Hold'em - Logged In As xxxx")
|
||||||
|
|
||||||
def testImportHandHistoryFiles(self):
|
def testEverleafGameInfoRegex(self):
|
||||||
"""Test import of single HH file"""
|
cash_nlhe = """Everleaf Gaming Game #55198191
|
||||||
self.mysqlimporter.addImportFile("regression-test-files/hand-histories/ps-lhe-ring-3hands.txt")
|
***** Hand history for game #55198191 *****
|
||||||
self.mysqlimporter.runImport()
|
Blinds $0.50/$1 NL Hold'em - 2008/09/01 - 10:02:11
|
||||||
self.mysqlimporter.addImportDirectory("regression-test-files/hand-histories")
|
Table Speed Kuala
|
||||||
self.mysqlimporter.runImport()
|
Seat 8 is the button
|
||||||
|
Total number of players: 10"""
|
||||||
|
cash_plo = """Everleaf Gaming Game #65295370
|
||||||
|
***** Hand history for game #65295370 *****
|
||||||
|
Blinds $0.50/$1 PL Omaha - 2008/12/07 - 21:59:48
|
||||||
|
Table Guanajuato
|
||||||
|
Seat 5 is the button
|
||||||
|
Total number of players: 6"""
|
||||||
|
cash_flhe = """Everleaf Gaming Game #55809022
|
||||||
|
***** Hand history for game #55809022 *****
|
||||||
|
$1/$2 Hold'em - 2008/09/07 - 08:04:36
|
||||||
|
Table Jeonju
|
||||||
|
Seat 4 is the button
|
||||||
|
Total number of players: 5
|
||||||
|
"""
|
||||||
|
#NLHE
|
||||||
|
m = self.everleaf.re_GameInfo.search(cash_nlhe)
|
||||||
|
sb = m.group('SB')
|
||||||
|
bb = m.group('BB')
|
||||||
|
ltype = m.group('LTYPE')
|
||||||
|
game = m.group('GAME')
|
||||||
|
|
||||||
|
self.failUnless(sb == "0.50", "SB incorrect, expected: 0.50 got: '" + sb + "'")
|
||||||
|
self.failUnless(bb == "1", "BB incorrect, expected: 1 got: '" + bb + "'")
|
||||||
|
self.failUnless(ltype == "NL", "LTYPE incorrect, expected: NL got: '" + ltype + "'")
|
||||||
|
self.failUnless(game == "Hold\'em", "GAME incorrect, expected: Hold\'em got: '" + game + "'")
|
||||||
|
|
||||||
|
#FLHE
|
||||||
|
m = self.everleaf.re_GameInfo.search(cash_flhe)
|
||||||
|
sb = m.group('SB')
|
||||||
|
bb = m.group('BB')
|
||||||
|
ltype = m.group('LTYPE')
|
||||||
|
game = m.group('GAME')
|
||||||
|
print m.groups()
|
||||||
|
|
||||||
|
self.failUnless(sb == "1", "SB incorrect, expected: 1 got: '" + sb + "'")
|
||||||
|
self.failUnless(bb == "2", "BB incorrect, expected: 2 got: '" + bb + "'")
|
||||||
|
self.failUnless(ltype == None, "LTYPE incorrect, expected: NL got: '%s'" %(ltype))
|
||||||
|
self.failUnless(game == "Hold\'em", "GAME incorrect, expected: Hold\'em got: '" + game + "'")
|
||||||
|
|
||||||
|
# def testImportHandHistoryFiles(self):
|
||||||
|
# """Test import of single HH file"""
|
||||||
|
# self.mysqlimporter.addImportFile("regression-test-files/hand-histories/ps-lhe-ring-3hands.txt")
|
||||||
|
# self.mysqlimporter.runImport()
|
||||||
|
# self.mysqlimporter.addImportDirectory("regression-test-files/hand-histories")
|
||||||
|
# self.mysqlimporter.runImport()
|
||||||
|
|
||||||
# def testPostgresSQLRecreateTables(self):
|
# def testPostgresSQLRecreateTables(self):
|
||||||
# """Test droping then recreating fpdb table schema"""
|
# """Test droping then recreating fpdb table schema"""
|
||||||
|
|
|
@ -75,7 +75,7 @@ def totalprofit(stat_dict, player):
|
||||||
if stat_dict[player]['net'] != 0:
|
if stat_dict[player]['net'] != 0:
|
||||||
stat = float(stat_dict[player]['net']) / 100
|
stat = float(stat_dict[player]['net']) / 100
|
||||||
return (stat, '$%.2f' % stat, 'tp=$%.2f' % stat, 'totalprofit=$%.2f' % stat, str(stat), 'Total Profit')
|
return (stat, '$%.2f' % stat, 'tp=$%.2f' % stat, 'totalprofit=$%.2f' % stat, str(stat), 'Total Profit')
|
||||||
return ('0', '0', '0', '0', 'Total Profit')
|
return ('0', '$0.00', 'tp=0', 'totalprofit=0', '0', 'Total Profit')
|
||||||
|
|
||||||
def playername(stat_dict, player):
|
def playername(stat_dict, player):
|
||||||
""" Player Name."""
|
""" Player Name."""
|
||||||
|
|
|
@ -38,6 +38,7 @@ import fpdb_db
|
||||||
import fpdb_simple
|
import fpdb_simple
|
||||||
import GuiBulkImport
|
import GuiBulkImport
|
||||||
import GuiPlayerStats
|
import GuiPlayerStats
|
||||||
|
import GuiPositionalStats
|
||||||
import GuiTableViewer
|
import GuiTableViewer
|
||||||
import GuiAutoImport
|
import GuiAutoImport
|
||||||
import GuiGraphViewer
|
import GuiGraphViewer
|
||||||
|
@ -341,6 +342,12 @@ class fpdb:
|
||||||
ps_tab=new_ps_thread.get_vbox()
|
ps_tab=new_ps_thread.get_vbox()
|
||||||
self.add_and_display_tab(ps_tab, "Player Stats")
|
self.add_and_display_tab(ps_tab, "Player Stats")
|
||||||
|
|
||||||
|
def tab_positional_stats(self, widget, data):
|
||||||
|
new_ps_thread=GuiPositionalStats.GuiPositionalStats(self.db, self.config, self.querydict)
|
||||||
|
self.threads.append(new_ps_thread)
|
||||||
|
ps_tab=new_ps_thread.get_vbox()
|
||||||
|
self.add_and_display_tab(ps_tab, "Ppositional Stats")
|
||||||
|
|
||||||
|
|
||||||
def tab_main_help(self, widget, data):
|
def tab_main_help(self, widget, data):
|
||||||
"""Displays a tab with the main fpdb help screen"""
|
"""Displays a tab with the main fpdb help screen"""
|
||||||
|
@ -401,6 +408,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
||||||
("/Viewers/Hand _Replayer (todo)", None, self.not_implemented, 0, None ),
|
("/Viewers/Hand _Replayer (todo)", None, self.not_implemented, 0, None ),
|
||||||
("/Viewers/Player _Details (todo)", None, self.not_implemented, 0, None ),
|
("/Viewers/Player _Details (todo)", None, self.not_implemented, 0, None ),
|
||||||
("/Viewers/_Player Stats (tabulated view)", None, self.tab_player_stats, 0, None ),
|
("/Viewers/_Player Stats (tabulated view)", None, self.tab_player_stats, 0, None ),
|
||||||
|
("/Viewers/Positional Stats (tabulated view)", None, self.tab_positional_stats, 0, None ),
|
||||||
("/Viewers/Starting _Hands (todo)", None, self.not_implemented, 0, None ),
|
("/Viewers/Starting _Hands (todo)", None, self.not_implemented, 0, None ),
|
||||||
("/Viewers/_Session Replayer (todo)", None, self.not_implemented, 0, None ),
|
("/Viewers/_Session Replayer (todo)", None, self.not_implemented, 0, None ),
|
||||||
("/Viewers/Poker_table Viewer (mostly obselete)", "<control>T", self.tab_table_viewer, 0, None ),
|
("/Viewers/Poker_table Viewer (mostly obselete)", "<control>T", self.tab_table_viewer, 0, None ),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user