First pass at turning file from pokerstats into class
This commit is contained in:
parent
7bc686c859
commit
d6706a5bdf
|
@ -8,6 +8,9 @@
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, version 3 of the License.
|
# the Free Software Foundation, version 3 of the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Modified for use in fpdb by Carl Gherardi
|
||||||
|
|
||||||
from errors import *
|
from errors import *
|
||||||
import re
|
import re
|
||||||
import regex
|
import regex
|
||||||
|
@ -22,58 +25,133 @@ import regex
|
||||||
# the hand history title line. Hence, to allow these strangely saved
|
# the hand history title line. Hence, to allow these strangely saved
|
||||||
# hands to be parsed and imported, there is a conditional "one extra
|
# hands to be parsed and imported, there is a conditional "one extra
|
||||||
# character" allowed at the start of the new hand regex.
|
# character" allowed at the start of the new hand regex.
|
||||||
__NEW_HAND_REGEX='^.?PokerStars Game #\d+:\s+Hold\'em'
|
|
||||||
__HAND_INFO_REGEX='^.*#(\d+):\s+(\S+)\s([\s\S]+)\s\(\$?([.0-9]+)/\$?([.0-9]+)\)\s-\s(\S+)\s-?\s?(\S+)\s\(?(\w+)\)?'
|
|
||||||
__TABLE_INFO_REGEX='^\S+\s+\'.*\'\s+(\d+)-max\s+Seat\s#(\d+)'
|
|
||||||
__PLAYER_INFO_REGEX='^Seat\s(\d+):\s(.*)\s\(\$?([.\d]+)\s'
|
|
||||||
__POST_SB_REGEX='^(.*):\sposts small blind'
|
|
||||||
__POST_BB_REGEX='^(.*):\sposts big blind'
|
|
||||||
__POST_BOTH_REGEX='^(.*):\sposts small & big blinds'
|
|
||||||
__HAND_STAGE_REGEX='^\*{3}\s(.*)\s\*{3}'
|
|
||||||
__HOLE_CARD_REGEX='^\*{3}\sHOLE CARDS'
|
|
||||||
__FLOP_CARD_REGEX='^\*{3}\sFLOP\s\*{3}\s\[(\S{2})\s(\S{2})\s(\S{2})\]'
|
|
||||||
__TURN_CARD_REGEX='^\*{3}\sTURN\s\*{3}\s\[\S{2}\s\S{2}\s\S{2}\]\s\[(\S{2})\]'
|
|
||||||
__RIVER_CARD_REGEX='^\*{3}\sRIVER\s\*{3}\s\[\S{2}\s\S{2}\s\S{2}\s\S{2}\]\s\[(\S{2})\]'
|
|
||||||
__SHOWDOWN_REGEX='^\*{3}\sSHOW DOWN'
|
|
||||||
__SUMMARY_REGEX='^\*{3}\sSUMMARY'
|
|
||||||
__UNCALLED_BET_REGEX='^Uncalled bet \(\$([.\d]+)\) returned to (.*)'
|
|
||||||
__POT_AND_RAKE_REGEX='^Total\spot\s\$([.\d]+).*\|\sRake\s\$([.\d]+)'
|
|
||||||
__COLLECT_POT_REGEX='^(.*)\scollected\s\$([.\d]+)\sfrom\s((main|side)\s)?pot'
|
|
||||||
__POCKET_CARDS_REGEX='^Dealt\sto\s(.*)\s\[(\S{2})\s(\S{2})\]'
|
|
||||||
__SHOWN_CARDS_REGEX='^(.*):\sshows\s\[(\S{2})\s(\S{2})\]'
|
|
||||||
__ACTION_STEP_REGEX='^(.*):\s(bets|checks|raises|calls|folds)((\s\$([.\d]+))?(\sto\s\$([.\d]+))?)?'
|
|
||||||
|
|
||||||
__SHOWDOWN_ACTION_REGEX='^(.*):\s(shows|mucks)'
|
|
||||||
__SUMMARY_CARDS_REGEX='^Seat\s\d+:\s(.*)\s(showed|mucked)\s\[(\S{2})\s(\S{2})\]'
|
|
||||||
__SUMMARY_CARDS_EXTRA_REGEX='^Seat\s\d+:\s(.*)\s(\(.*\)\s)(showed|mucked)\s\[(\S{2})\s(\S{2})\]'
|
|
||||||
|
|
||||||
|
|
||||||
def regexes():
|
class FpdbRegex:
|
||||||
m = regex.RegexMatch()
|
def __init__(self):
|
||||||
### Compile the regexes
|
__NEW_HAND_REGEX='^.?PokerStars Game #\d+:\s+Hold\'em'
|
||||||
m.hand_start_re = re.compile(__NEW_HAND_REGEX)
|
__HAND_INFO_REGEX='^.*#(\d+):\s+(\S+)\s([\s\S]+)\s\(\$?([.0-9]+)/\$?([.0-9]+)\)\s-\s(\S+)\s-?\s?(\S+)\s\(?(\w+)\)?'
|
||||||
m.hand_info_re = re.compile(__HAND_INFO_REGEX)
|
__TABLE_INFO_REGEX='^\S+\s+\'.*\'\s+(\d+)-max\s+Seat\s#(\d+)'
|
||||||
m.table_info_re = re.compile(__TABLE_INFO_REGEX)
|
__PLAYER_INFO_REGEX='^Seat\s(\d+):\s(.*)\s\(\$?([.\d]+)\s'
|
||||||
m.player_info_re = re.compile(__PLAYER_INFO_REGEX)
|
__POST_SB_REGEX='^(.*):\sposts small blind'
|
||||||
m.small_blind_re = re.compile(__POST_SB_REGEX)
|
__POST_BB_REGEX='^(.*):\sposts big blind'
|
||||||
m.big_blind_re = re.compile(__POST_BB_REGEX)
|
__POST_BOTH_REGEX='^(.*):\sposts small & big blinds'
|
||||||
m.both_blinds_re = re.compile(__POST_BOTH_REGEX)
|
__HAND_STAGE_REGEX='^\*{3}\s(.*)\s\*{3}'
|
||||||
m.hand_stage_re = re.compile(__HAND_STAGE_REGEX)
|
__HOLE_CARD_REGEX='^\*{3}\sHOLE CARDS'
|
||||||
m.hole_cards_re = re.compile(__HOLE_CARD_REGEX)
|
__FLOP_CARD_REGEX='^\*{3}\sFLOP\s\*{3}\s\[(\S{2})\s(\S{2})\s(\S{2})\]'
|
||||||
m.flop_cards_re = re.compile(__FLOP_CARD_REGEX)
|
__TURN_CARD_REGEX='^\*{3}\sTURN\s\*{3}\s\[\S{2}\s\S{2}\s\S{2}\]\s\[(\S{2})\]'
|
||||||
m.turn_card_re = re.compile(__TURN_CARD_REGEX)
|
__RIVER_CARD_REGEX='^\*{3}\sRIVER\s\*{3}\s\[\S{2}\s\S{2}\s\S{2}\s\S{2}\]\s\[(\S{2})\]'
|
||||||
m.river_card_re = re.compile(__RIVER_CARD_REGEX)
|
__SHOWDOWN_REGEX='^\*{3}\sSHOW DOWN'
|
||||||
m.showdown_re = re.compile(__SHOWDOWN_REGEX)
|
__SUMMARY_REGEX='^\*{3}\sSUMMARY'
|
||||||
m.summary_re = re.compile(__SUMMARY_REGEX)
|
__UNCALLED_BET_REGEX='^Uncalled bet \(\$([.\d]+)\) returned to (.*)'
|
||||||
m.uncalled_bet_re = re.compile(__UNCALLED_BET_REGEX)
|
__POT_AND_RAKE_REGEX='^Total\spot\s\$([.\d]+).*\|\sRake\s\$([.\d]+)'
|
||||||
m.collect_pot_re = re.compile(__COLLECT_POT_REGEX)
|
__COLLECT_POT_REGEX='^(.*)\scollected\s\$([.\d]+)\sfrom\s((main|side)\s)?pot'
|
||||||
m.pocket_cards_re = re.compile(__POCKET_CARDS_REGEX)
|
__POCKET_CARDS_REGEX='^Dealt\sto\s(.*)\s\[(\S{2})\s(\S{2})\]'
|
||||||
m.cards_shown_re = re.compile(__SHOWN_CARDS_REGEX)
|
__SHOWN_CARDS_REGEX='^(.*):\sshows\s\[(\S{2})\s(\S{2})\]'
|
||||||
m.summary_cards_re = re.compile(__SUMMARY_CARDS_REGEX)
|
__ACTION_STEP_REGEX='^(.*):\s(bets|checks|raises|calls|folds)((\s\$([.\d]+))?(\sto\s\$([.\d]+))?)?'
|
||||||
m.summary_cards_extra_re = re.compile(__SUMMARY_CARDS_EXTRA_REGEX)
|
|
||||||
m.action_re = re.compile(__ACTION_STEP_REGEX)
|
__SHOWDOWN_ACTION_REGEX='^(.*):\s(shows|mucks)'
|
||||||
m.rake_re = re.compile(__POT_AND_RAKE_REGEX)
|
__SUMMARY_CARDS_REGEX='^Seat\s\d+:\s(.*)\s(showed|mucked)\s\[(\S{2})\s(\S{2})\]'
|
||||||
m.showdown_action_re = re.compile(__SHOWDOWN_ACTION_REGEX)
|
__SUMMARY_CARDS_EXTRA_REGEX='^Seat\s\d+:\s(.*)\s(\(.*\)\s)(showed|mucked)\s\[(\S{2})\s(\S{2})\]'
|
||||||
###
|
self.m = regex.RegexMatch()
|
||||||
return m
|
|
||||||
|
def getRegexes():
|
||||||
|
return self.m
|
||||||
|
|
||||||
|
def compileRegexes():
|
||||||
|
### Compile the regexes
|
||||||
|
m.hand_start_re = re.compile(__NEW_HAND_REGEX)
|
||||||
|
m.hand_info_re = re.compile(__HAND_INFO_REGEX)
|
||||||
|
m.table_info_re = re.compile(__TABLE_INFO_REGEX)
|
||||||
|
m.player_info_re = re.compile(__PLAYER_INFO_REGEX)
|
||||||
|
m.small_blind_re = re.compile(__POST_SB_REGEX)
|
||||||
|
m.big_blind_re = re.compile(__POST_BB_REGEX)
|
||||||
|
m.both_blinds_re = re.compile(__POST_BOTH_REGEX)
|
||||||
|
m.hand_stage_re = re.compile(__HAND_STAGE_REGEX)
|
||||||
|
m.hole_cards_re = re.compile(__HOLE_CARD_REGEX)
|
||||||
|
m.flop_cards_re = re.compile(__FLOP_CARD_REGEX)
|
||||||
|
m.turn_card_re = re.compile(__TURN_CARD_REGEX)
|
||||||
|
m.river_card_re = re.compile(__RIVER_CARD_REGEX)
|
||||||
|
m.showdown_re = re.compile(__SHOWDOWN_REGEX)
|
||||||
|
m.summary_re = re.compile(__SUMMARY_REGEX)
|
||||||
|
m.uncalled_bet_re = re.compile(__UNCALLED_BET_REGEX)
|
||||||
|
m.collect_pot_re = re.compile(__COLLECT_POT_REGEX)
|
||||||
|
m.pocket_cards_re = re.compile(__POCKET_CARDS_REGEX)
|
||||||
|
m.cards_shown_re = re.compile(__SHOWN_CARDS_REGEX)
|
||||||
|
m.summary_cards_re = re.compile(__SUMMARY_CARDS_REGEX)
|
||||||
|
m.summary_cards_extra_re = re.compile(__SUMMARY_CARDS_EXTRA_REGEX)
|
||||||
|
m.action_re = re.compile(__ACTION_STEP_REGEX)
|
||||||
|
m.rake_re = re.compile(__POT_AND_RAKE_REGEX)
|
||||||
|
m.showdown_action_re = re.compile(__SHOWDOWN_ACTION_REGEX)
|
||||||
|
|
||||||
|
# Set methods for plugins to override
|
||||||
|
|
||||||
|
def setNewHandRegex(self, string):
|
||||||
|
__NEW_HAND_REGEX = string
|
||||||
|
|
||||||
|
def setHandInfoRegex(self, string):
|
||||||
|
__HAND_INFO_REGEX = string
|
||||||
|
|
||||||
|
def setTableInfoRegex(self, string):
|
||||||
|
__TABLE_INFO_REGEX = string
|
||||||
|
|
||||||
|
def setPlayerInfoRegex(self, string):
|
||||||
|
__PLAYER_INFO_REGEX = string
|
||||||
|
|
||||||
|
def setPostSbRegex(self, string):
|
||||||
|
__POST_SB_REGEX = string
|
||||||
|
|
||||||
|
def setPostBbRegex(self, string):
|
||||||
|
__POST_BB_REGEX = string
|
||||||
|
|
||||||
|
def setPostBothRegex(self, string):
|
||||||
|
__POST_BOTH_REGEX = string
|
||||||
|
|
||||||
|
def setHandStageRegex(self, string):
|
||||||
|
__HAND_STAGE_REGEX = string
|
||||||
|
|
||||||
|
def setHoleCardRegex(self, string):
|
||||||
|
__HOLE_CARD_REGEX = string
|
||||||
|
|
||||||
|
def setFlopCardRegex(self, string):
|
||||||
|
__FLOP_CARD_REGEX = string
|
||||||
|
|
||||||
|
def setTurnCardRegex(self, string):
|
||||||
|
__TURN_CARD_REGEX = string
|
||||||
|
|
||||||
|
def setRiverCardRegex(self, string):
|
||||||
|
__RIVER_CARD_REGEX = string
|
||||||
|
|
||||||
|
def setShowdownRegex(self, string):
|
||||||
|
__SHOWDOWN_REGEX = string
|
||||||
|
|
||||||
|
def setSummaryRegex(self, string):
|
||||||
|
__SUMMARY_REGEX = string
|
||||||
|
|
||||||
|
def setUncalledBetRegex(self, string):
|
||||||
|
__UNCALLED_BET_REGEX = string
|
||||||
|
|
||||||
|
def setCollectPotRegex(self, string):
|
||||||
|
__COLLECT_POT_REGEX = string
|
||||||
|
|
||||||
|
def setPocketCardsRegex(self, string):
|
||||||
|
__POCKET_CARDS_REGEX = string
|
||||||
|
|
||||||
|
def setShownCardsRegex(self, string):
|
||||||
|
__SHOWN_CARDS_REGEX = string
|
||||||
|
|
||||||
|
def setSummaryCardsRegex(self, string):
|
||||||
|
__SUMMARY_CARDS_REGEX = string
|
||||||
|
|
||||||
|
def setSummaryCardsExtraRegex(self, string):
|
||||||
|
__SUMMARY_CARDS_EXTRA_REGEX = string
|
||||||
|
|
||||||
|
def setActionStepRegex(self, string):
|
||||||
|
__ACTION_STEP_REGEX = string
|
||||||
|
|
||||||
|
def setPotAndRakeRegex(self, string):
|
||||||
|
__POT_AND_RAKE_REGEX = string
|
||||||
|
|
||||||
|
def setShowdownActionRegex(self, string):
|
||||||
|
__SHOWDOWN_ACTION_REGEX = string
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user