From 816a9e3b581ba56319018e0bb2f16dc3a9a11031 Mon Sep 17 00:00:00 2001 From: Worros Date: Mon, 10 Nov 2008 23:02:56 +1000 Subject: [PATCH] More Everleaf converter updates, now parsing some hand info --- pyfpdb/EverleafToFpdb.py | 22 +++++++++++++++++++++- pyfpdb/HandHistoryConverter.py | 18 +++++++++++++----- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index f09c67d1..61e32d85 100644 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -60,7 +60,8 @@ class Everleaf(HandHistoryConverter): self.sitename = "Everleaf" self.setFileType("text") self.rexx.setGameInfoRegex('.*Blinds \$?(?P[.0-9]+)/\$?(?P[.0-9]+)') - self.rexx.setSplitHandRegex('\n\n\n') + self.rexx.setSplitHandRegex('\n\n\n\n') + self.rexx.setHandInfoRegex('.*#(?P[0-9]+)\n.*\nBlinds \$?(?P[.0-9]+)/\$?(?P[.0-9]+) (?P.*) - (?P[0-9]+)/(?P[0-9]+)/(?P[0-9]+) - (?P
[0-9]+):(?P[0-9]+):(?P[0-9]+)\nTable (?P[ a-zA-Z]+)') self.rexx.compileRegexes() def readSupportedGames(self): @@ -76,6 +77,25 @@ class Everleaf(HandHistoryConverter): return gametype + def readHandInfo(self, hand): + m = self.rexx.hand_info_re.search(hand.string) + hand.handid = m.group('HID') + hand.tablename = m.group('GAMETYPE') +# These work, but the info is already in the Hand class - should be usecd for tourneys though. +# m.group('SB') +# m.group('BB') +# m.group('GAMETYPE') + +# Believe Everleaf time is GMT/UTC, no transation necessary +# Stars format (Nov 10 2008): 2008/11/07 12:38:49 UTC [2008/11/07 7:38:49 ET] +# Not getting it in my HH files yet, so using +# 2008/11/10 3:58:52 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) + hand.starttime = "%d/%02d/%02d %d:%02d:%02d ET" %(int(m.group('YEAR')), int(m.group('MON')), int(m.group('DAY')), + int(m.group('HR')), int(m.group('MIN')), int(m.group('SEC'))) + + def readPlayerStacks(self): pass diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 508e253c..9a8fd456 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -61,6 +61,9 @@ class HandHistoryConverter: self.readFile(self.file) self.gametype = self.determineGameType() self.hands = self.splitFileIntoHands() + for hand in self.hands: + self.readHandInfo(hand) + self.writeHand("output file", hand) # Functions to be implemented in the inheriting class def readSupportedGames(self): abstract @@ -70,6 +73,7 @@ class HandHistoryConverter: # [ ring, hold, nl , sb, bb ] # Valid types specified in docs/tabledesign.html in Gametypes def determineGameType(self): abstract + def readHandInfo(self, hand): abstract def readPlayerStacks(self): abstract def readBlinds(self): abstract def readAction(self): abstract @@ -102,7 +106,9 @@ class HandHistoryConverter: def splitFileIntoHands(self): hands = [] list = self.rexx.split_hand_re.split(self.obs) + list.pop() #Last entry is empty for l in list: +# print "'" + l + "'" hands = hands + [Hand(self.sitename, self.gametype, l)] return hands @@ -122,8 +128,8 @@ class HandHistoryConverter: 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" + print "%s Game #%s: %s (%d/%d) - %s" %(hand.sitename, hand.handid, "XXXXhand.gametype", hand.sb, hand.bb, hand.starttime) + print "Table '%s' %d-max Seat #%s is the button" %(hand.tablename, hand.maxseats, "XXXXhand.buttonpos") # # counter = 1 # for player in seating: @@ -132,12 +138,12 @@ class HandHistoryConverter: # print playername + ": posts small blind " + sb # print playername + ": posts big blind " + bb # -# print "*** HOLE CARDS ***" + print "*** HOLE CARDS ***" # print "Dealt to " + hero + " [" + holecards + "]" # ## ACTION STUFF # -# print "*** SUMMARY ***" + print "*** SUMMARY ***" # print "Total pot $" + totalpot + " | Rake $" + rake # print "Board [" + boardcards + "]" # @@ -166,7 +172,9 @@ class Hand: self.gametype = gametype self.string = string - self.handid = None + self.handid = 0 + self.sb = gametype[3] + self.bb = gametype[4] self.tablename = "Slartibartfast" self.maxseats = 10 self.counted_seats = 0