Lots of changes. Fixes the hud for auto-import - at least for me.

Does configer Importer to use the Config class.
This commit is contained in:
Worros 2008-11-09 21:57:58 +10:00
parent d0218363c6
commit d4038c3f19
8 changed files with 162 additions and 92 deletions

View File

@ -53,7 +53,7 @@ if __name__ == "__main__":
(options, sys.argv) = parser.parse_args()
settings={'imp-callFpdbHud':False, 'db-backend':2}
settings={'callFpdbHud':False, 'db-backend':2}
settings['db-host']=options.server
settings['db-user']=options.user
settings['db-password']=options.password

View File

@ -443,8 +443,8 @@ class Config:
imp['interval'] = self.interval
imp['hhArchiveBase'] = self.hhArchiveBase
except: # Default params
imp['callFpdbHud'] = 10
imp['interval'] = True
imp['callFpdbHud'] = True
imp['interval'] = 10
imp['hhArchiveBase'] = "~/.fpdb/HandHistories/"
return imp

View File

@ -17,7 +17,41 @@
########################################################################
import Configuration
from HandHistoryConverter import HandHistoryConverter
from HandHistoryConverter import *
# Everleaf HH format
#Everleaf Gaming Game #55198191
#***** Hand history for game #55198191 *****
#Blinds $0.50/$1 NL Hold'em - 2008/09/01 - 10:02:11
#Table Speed Kuala
#Seat 8 is the button
#Total number of players: 10
#Seat 1: spicybum ( $ 77.50 USD )
#Seat 2: harrydebeng ( new player )
#Seat 3: EricBlade ( new player )
#Seat 4: dollar_hecht ( $ 16.40 USD )
#Seat 5: Apolon76 ( $ 154.10 USD )
#Seat 6: dogge ( new player )
#Seat 7: RonKoro ( $ 25.53 USD )
#Seat 8: jay68w ( $ 48.50 USD )
#Seat 9: KillerQueen1 ( $ 51.28 USD )
#Seat 10: Cheburashka ( $ 49.61 USD )
#KillerQueen1: posts small blind [$ 0.50 USD]
#Cheburashka: posts big blind [$ 1 USD]
#** Dealing down cards **
#spicybum folds
#dollar_hecht calls [$ 1 USD]
#Apolon76 folds
#RonKoro folds
#jay68w raises [$ 4.50 USD]
#KillerQueen1 folds
#Cheburashka folds
#dollar_hecht folds
#jay68w does not show cards
#jay68w wins $ 3.50 USD from main pot
class Everleaf(HandHistoryConverter):
def __init__(self, config, file):
@ -25,12 +59,16 @@ class Everleaf(HandHistoryConverter):
HandHistoryConverter.__init__(self, config, file, "Everleaf") # Call super class init.
self.sitename = "Everleaf"
self.setFileType("text")
self.rexx.setSplitHandRegex("\n\n\n")
self.rexx.compileRegexes()
def readSupportedGames(self):
pass
def determineGameType(self):
pass
gametype = ["ring", "hold", "nl"]
return gametype
def readPlayerStacks(self):
pass
@ -45,5 +83,5 @@ if __name__ == "__main__":
c = Configuration.Config()
e = Everleaf(c, "regression-test-files/everleaf/Speed_Kuala.txt")
e.processFile()
print str(e)
# print str(e)

View File

@ -12,7 +12,6 @@
# Modified for use in fpdb by Carl Gherardi
import re
import regex
# These are PokerStars specific;
# More importantly, they are currently valid for cash game only.
@ -28,129 +27,130 @@ import regex
class FpdbRegex:
def __init__(self):
__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]+))?)?'
self.__SPLIT_HAND_REGEX='\n\n\n'
self.__NEW_HAND_REGEX='^.?PokerStars Game #\d+:\s+Hold\'em'
self.__HAND_INFO_REGEX='^.*#(\d+):\s+(\S+)\s([\s\S]+)\s\(\$?([.0-9]+)/\$?([.0-9]+)\)\s-\s(\S+)\s-?\s?(\S+)\s\(?(\w+)\)?'
self.__TABLE_INFO_REGEX='^\S+\s+\'.*\'\s+(\d+)-max\s+Seat\s#(\d+)'
self.__PLAYER_INFO_REGEX='^Seat\s(\d+):\s(.*)\s\(\$?([.\d]+)\s'
self.__POST_SB_REGEX='^(.*):\sposts small blind'
self.__POST_BB_REGEX='^(.*):\sposts big blind'
self.__POST_BOTH_REGEX='^(.*):\sposts small & big blinds'
self.__HAND_STAGE_REGEX='^\*{3}\s(.*)\s\*{3}'
self.__HOLE_CARD_REGEX='^\*{3}\sHOLE CARDS'
self.__FLOP_CARD_REGEX='^\*{3}\sFLOP\s\*{3}\s\[(\S{2})\s(\S{2})\s(\S{2})\]'
self.__TURN_CARD_REGEX='^\*{3}\sTURN\s\*{3}\s\[\S{2}\s\S{2}\s\S{2}\]\s\[(\S{2})\]'
self.__RIVER_CARD_REGEX='^\*{3}\sRIVER\s\*{3}\s\[\S{2}\s\S{2}\s\S{2}\s\S{2}\]\s\[(\S{2})\]'
self.__SHOWDOWN_REGEX='^\*{3}\sSHOW DOWN'
self.__SUMMARY_REGEX='^\*{3}\sSUMMARY'
self.__UNCALLED_BET_REGEX='^Uncalled bet \(\$([.\d]+)\) returned to (.*)'
self.__POT_AND_RAKE_REGEX='^Total\spot\s\$([.\d]+).*\|\sRake\s\$([.\d]+)'
self.__COLLECT_POT_REGEX='^(.*)\scollected\s\$([.\d]+)\sfrom\s((main|side)\s)?pot'
self.__POCKET_CARDS_REGEX='^Dealt\sto\s(.*)\s\[(\S{2})\s(\S{2})\]'
self.__SHOWN_CARDS_REGEX='^(.*):\sshows\s\[(\S{2})\s(\S{2})\]'
self.__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})\]'
self.m = regex.RegexMatch()
self.__SHOWDOWN_ACTION_REGEX='^(.*):\s(shows|mucks)'
self.__SUMMARY_CARDS_REGEX='^Seat\s\d+:\s(.*)\s(showed|mucked)\s\[(\S{2})\s(\S{2})\]'
self.__SUMMARY_CARDS_EXTRA_REGEX='^Seat\s\d+:\s(.*)\s(\(.*\)\s)(showed|mucked)\s\[(\S{2})\s(\S{2})\]'
def getRegexes():
return self.m
def compileRegexes():
def compileRegexes(self):
### 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)
self.split_hand_re = re.compile(self.__SPLIT_HAND_REGEX)
self.hand_start_re = re.compile(self.__NEW_HAND_REGEX)
self.hand_info_re = re.compile(self.__HAND_INFO_REGEX)
self.table_info_re = re.compile(self.__TABLE_INFO_REGEX)
self.player_info_re = re.compile(self.__PLAYER_INFO_REGEX)
self.small_blind_re = re.compile(self.__POST_SB_REGEX)
self.big_blind_re = re.compile(self.__POST_BB_REGEX)
self.both_blinds_re = re.compile(self.__POST_BOTH_REGEX)
self.hand_stage_re = re.compile(self.__HAND_STAGE_REGEX)
self.hole_cards_re = re.compile(self.__HOLE_CARD_REGEX)
self.flop_cards_re = re.compile(self.__FLOP_CARD_REGEX)
self.turn_card_re = re.compile(self.__TURN_CARD_REGEX)
self.river_card_re = re.compile(self.__RIVER_CARD_REGEX)
self.showdown_re = re.compile(self.__SHOWDOWN_REGEX)
self.summary_re = re.compile(self.__SUMMARY_REGEX)
self.uncalled_bet_re = re.compile(self.__UNCALLED_BET_REGEX)
self.collect_pot_re = re.compile(self.__COLLECT_POT_REGEX)
self.pocket_cards_re = re.compile(self.__POCKET_CARDS_REGEX)
self.cards_shown_re = re.compile(self.__SHOWN_CARDS_REGEX)
self.summary_cards_re = re.compile(self.__SUMMARY_CARDS_REGEX)
self.summary_cards_extra_re = re.compile(self.__SUMMARY_CARDS_EXTRA_REGEX)
self.action_re = re.compile(self.__ACTION_STEP_REGEX)
self.rake_re = re.compile(self.__POT_AND_RAKE_REGEX)
self.showdown_action_re = re.compile(self.__SHOWDOWN_ACTION_REGEX)
# Set methods for plugins to override
def setSplitHandRegex(self, string):
self.__SPLIT_HAND_REGEX = string
def setNewHandRegex(self, string):
__NEW_HAND_REGEX = string
self.__NEW_HAND_REGEX = string
def setHandInfoRegex(self, string):
__HAND_INFO_REGEX = string
self.__HAND_INFO_REGEX = string
def setTableInfoRegex(self, string):
__TABLE_INFO_REGEX = string
self.__TABLE_INFO_REGEX = string
def setPlayerInfoRegex(self, string):
__PLAYER_INFO_REGEX = string
self.__PLAYER_INFO_REGEX = string
def setPostSbRegex(self, string):
__POST_SB_REGEX = string
self.__POST_SB_REGEX = string
def setPostBbRegex(self, string):
__POST_BB_REGEX = string
self.__POST_BB_REGEX = string
def setPostBothRegex(self, string):
__POST_BOTH_REGEX = string
self.__POST_BOTH_REGEX = string
def setHandStageRegex(self, string):
__HAND_STAGE_REGEX = string
self.__HAND_STAGE_REGEX = string
def setHoleCardRegex(self, string):
__HOLE_CARD_REGEX = string
self.__HOLE_CARD_REGEX = string
def setFlopCardRegex(self, string):
__FLOP_CARD_REGEX = string
self.__FLOP_CARD_REGEX = string
def setTurnCardRegex(self, string):
__TURN_CARD_REGEX = string
self.__TURN_CARD_REGEX = string
def setRiverCardRegex(self, string):
__RIVER_CARD_REGEX = string
self.__RIVER_CARD_REGEX = string
def setShowdownRegex(self, string):
__SHOWDOWN_REGEX = string
self.__SHOWDOWN_REGEX = string
def setSummaryRegex(self, string):
__SUMMARY_REGEX = string
self.__SUMMARY_REGEX = string
def setUncalledBetRegex(self, string):
__UNCALLED_BET_REGEX = string
self.__UNCALLED_BET_REGEX = string
def setCollectPotRegex(self, string):
__COLLECT_POT_REGEX = string
self.__COLLECT_POT_REGEX = string
def setPocketCardsRegex(self, string):
__POCKET_CARDS_REGEX = string
self.__POCKET_CARDS_REGEX = string
def setShownCardsRegex(self, string):
__SHOWN_CARDS_REGEX = string
self.__SHOWN_CARDS_REGEX = string
def setSummaryCardsRegex(self, string):
__SUMMARY_CARDS_REGEX = string
self.__SUMMARY_CARDS_REGEX = string
def setSummaryCardsExtraRegex(self, string):
__SUMMARY_CARDS_EXTRA_REGEX = string
self.__SUMMARY_CARDS_EXTRA_REGEX = string
def setActionStepRegex(self, string):
__ACTION_STEP_REGEX = string
self.__ACTION_STEP_REGEX = string
def setPotAndRakeRegex(self, string):
__POT_AND_RAKE_REGEX = string
self.__POT_AND_RAKE_REGEX = string
def setShowdownActionRegex(self, string):
__SHOWDOWN_ACTION_REGEX = string
self.__SHOWDOWN_ACTION_REGEX = string

View File

@ -33,9 +33,14 @@ class GuiAutoImport (threading.Thread):
self.settings=settings
self.config=config
imp = self.config.get_import_parameters()
print "Import parameters"
print imp
self.input_settings = {}
self.importer = fpdb_import.Importer(self,self.settings)
self.importer = fpdb_import.Importer(self,self.settings, self.config)
self.importer.setCallHud(True)
self.importer.setMinPrint(30)
self.importer.setQuiet(False)
@ -195,7 +200,7 @@ if __name__== "__main__":
settings['db-databaseName'] = "fpdb"
settings['hud-defaultInterval'] = 10
settings['hud-defaultPath'] = 'C:/Program Files/PokerStars/HandHistory/nutOmatic'
settings['imp-callFpdbHud'] = True
settings['callFpdbHud'] = True
i = GuiAutoImport(settings)
main_window = gtk.Window()

View File

@ -80,7 +80,7 @@ class GuiBulkImport (threading.Thread):
self.db=db
self.settings=settings
self.config=config
self.importer = fpdb_import.Importer(self,self.settings)
self.importer = fpdb_import.Importer(self,self.settings, config)
self.vbox=gtk.VBox(False,1)
self.vbox.show()

View File

@ -16,7 +16,8 @@
#agpl-3.0.txt in the docs folder of the package.
import Configuration
#import FpdbRegex
import FpdbRegex
import re
import sys
import traceback
import os
@ -38,6 +39,7 @@ class HandHistoryConverter:
self.hhdir = os.path.join(self.hhbase,sitename)
self.gametype = []
# self.ofile = os.path.join(self.hhdir,file)
self.rexx = FpdbRegex.FpdbRegex()
def __str__(self):
tmp = "HandHistoryConverter: '%s'\n" % (self.sitename)
@ -95,6 +97,13 @@ class HandHistoryConverter:
return
self.readFile(self.file)
self.gametype = self.determineGameType()
self.splitFileIntoHands()
def splitFileIntoHands(self):
hands = []
list = self.rexx.split_hand_re.split(self.obs)
for l in list:
hands = hands + [Hand(l)]
def readFile(self, filename):
"""Read file"""
@ -110,7 +119,7 @@ class HandHistoryConverter:
except:
traceback.print_exc(file=sys.stderr)
def writeStars(self):
def writeHand(self, file, hand):
"""Write out parsed data"""
# print sitename + " Game #" + handid + ": " + gametype + " (" + sb + "/" + bb + " - " + starttime
# print "Table '" + tablename + "' " + maxseats + "-max Seat #" + buttonpos + " is the button"
@ -148,3 +157,23 @@ class HandHistoryConverter:
result*=100
return result
#end def float2int
class Hand:
# def __init__(self, sitename, gametype, sb, bb, string):
def __init__(self, string):
# self.sitename = sitename
# self.gametype = gametype
# self.sb = sb
# self.bb = bb
self.string = string
print string
self.handid = None
self.tablename = "Slartibartfast"
self.maxseats = 10
self.counted_seats = 0
self.buttonpos = 0
self.seating = []
self.players = []
self.action = []

View File

@ -41,23 +41,22 @@ from time import time
class Importer:
def __init__(self, caller, settings):
def __init__(self, caller, settings, config):
"""Constructor"""
self.settings=settings
self.caller=caller
self.config = config
self.db = None
self.cursor = None
self.filelist = {}
self.dirlist = {}
self.monitor = False
self.updated = {} #Time last import was run {file:mtime}
self.callHud = False
self.lines = None
self.faobs = None #File as one big string
self.pos_in_file = {} # dict to remember how far we have read in the file
#Set defaults
if not self.settings.has_key('imp-callFpdbHud'):
self.settings['imp-callFpdbHud'] = False
self.callHud = self.config.get_import_parameters().get("callFpdbHud")
if not self.settings.has_key('minPrint'):
self.settings['minPrint'] = 30
self.dbConnect()
@ -237,8 +236,7 @@ class Importer:
stored+=1
self.db.commit()
# if settings['imp-callFpdbHud'] and self.callHud and os.sep=='/':
if self.settings['imp-callFpdbHud'] and self.callHud:
if self.callHud:
#print "call to HUD here. handsId:",handsId
#pipe the Hands.id out to the HUD
self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep)