diff --git a/pyfpdb/AbsoluteToFpdb.py b/pyfpdb/AbsoluteToFpdb.py index ed549519..234c1ce4 100755 --- a/pyfpdb/AbsoluteToFpdb.py +++ b/pyfpdb/AbsoluteToFpdb.py @@ -195,12 +195,11 @@ class Absolute(HandHistoryConverter): if m is None or fname_info is None: if m is None: - logging.info(_("Didn't match re_HandInfo")) - logging.info(hand.handText) + logging.error(_("Didn't match re_HandInfo")) + logging.error(hand.handText) elif fname_info is None: logging.info(_("File name didn't match re_*InfoFromFilename")) logging.info(_("File name: %s") % self.in_path) - return None logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE'))) hand.handid = m.group('HID') if m.group('TABLE'): diff --git a/pyfpdb/Anonymise.py b/pyfpdb/Anonymise.py old mode 100755 new mode 100644 index ffaa6e70..166651e8 --- a/pyfpdb/Anonymise.py +++ b/pyfpdb/Anonymise.py @@ -39,17 +39,17 @@ obj = getattr(mod, filter_name, None) hhc = obj(config, autostart=False) -if os.path.exists(options.infile): - in_fh = codecs.open(options.infile, 'r', "utf8") +if os.path.exists(options.filename): + in_fh = codecs.open(options.filename, 'r', "utf8") filecontents = in_fh.read() in_fh.close() else: - print _("Could not find file %s") % options.infile + print _("Could not find file %s") % options.filename exit(1) m = hhc.re_PlayerInfo.finditer(filecontents) -outfile = options.infile+".anon" +outfile = options.filename+".anon" print _("Output being written to"), outfile savestdout = sys.stdout diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index a1cac57a..756dd494 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -50,7 +50,7 @@ class Fulltilt(HandHistoryConverter): (Ante\s\$?(?P[.0-9]+)\s)?-\s [%(LS)s]?(?P[.0-9]+\sCap\s)? (?P(No\sLimit|Pot\sLimit|Limit))?\s - (?P(Hold\'em|Omaha\sHi|Omaha\sH/L|7\sCard\sStud|Stud\sH/L|Razz|Stud\sHi)) + (?P(Hold\'em|Omaha\sHi|Omaha\sH/L|7\sCard\sStud|Stud\sH/L|Razz|Stud\sHi|2-7\sTriple\sDraw|5\sCard\sDraw|Badugi)) ''' % substitutions, re.VERBOSE) re_SplitHands = re.compile(r"\n\n\n+") re_TailSplitHands = re.compile(r"(\n\n+)") @@ -62,7 +62,7 @@ class Fulltilt(HandHistoryConverter): (\((?P.+)\)\s)?-\s [%(LS)s]?(?P[.0-9]+)/[%(LS)s]?(?P[.0-9]+)\s(Ante\s[%(LS)s]?(?P[.0-9]+)\s)?-\s [%(LS)s]?(?P[.0-9]+\sCap\s)? - (?P[a-zA-Z\/\'\s]+)\s-\s + (?P[-\da-zA-Z\/\'\s]+)\s-\s (?P\d+:\d+:\d+\s(?P\w+)\s-\s\d+/\d+/\d+|\d+:\d+\s(?P\w+)\s-\s\w+\,\s\w+\s\d+\,\s\d+) (?P\(partial\))?\n (?:.*?\n(?PHand\s\#(?P=HID)\shas\sbeen\scanceled))? @@ -160,6 +160,10 @@ class Fulltilt(HandHistoryConverter): ["ring", "stud", "fl"], + ["ring", "draw", "fl"], + ["ring", "draw", "pl"], + ["ring", "draw", "nl"], + ["tour", "hold", "nl"], ["tour", "hold", "pl"], ["tour", "hold", "fl"], @@ -191,7 +195,10 @@ class Fulltilt(HandHistoryConverter): 'Omaha H/L' : ('hold','omahahilo'), 'Razz' : ('stud','razz'), 'Stud Hi' : ('stud','studhi'), - 'Stud H/L' : ('stud','studhilo') + 'Stud H/L' : ('stud','studhilo'), + '2-7 Triple Draw' : ('draw','27_3draw'), + '5 Card Draw' : ('draw','fivedraw'), + 'Badugi' : ('draw','badugi'), } currencies = { u'€':'EUR', '$':'USD', '':'T$' } if mg['CAP']: @@ -212,8 +219,8 @@ class Fulltilt(HandHistoryConverter): def readHandInfo(self, hand): m = self.re_HandInfo.search(hand.handText) if m is None: - logging.info(_("Didn't match re_HandInfo")) - logging.info(hand.handText) + tmp = hand.handText[0:100] + log.error(_("readHandInfo: Unable to recognise handinfo from: '%s'") % tmp) raise FpdbParseError(_("No match in readHandInfo.")) hand.handid = m.group('HID') hand.tablename = m.group('TABLE') @@ -279,20 +286,6 @@ class Fulltilt(HandHistoryConverter): if hand.level is None: hand.level = "0" -# 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') - -# 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 -# 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, hand): # Split hand text for FTP, as the regex matches the player names incorrectly # in the summary section @@ -305,21 +298,28 @@ class Fulltilt(HandHistoryConverter): for a in m: hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH')) + def markStreets(self, hand): - # PREFLOP = ** Dealing down cards ** if hand.gametype['base'] == 'hold': m = re.search(r"\*\*\* HOLE CARDS \*\*\*(?P.+(?=\*\*\* FLOP \*\*\*)|.+)" r"(\*\*\* FLOP \*\*\*(?P \[\S\S \S\S \S\S\].+(?=\*\*\* TURN \*\*\*)|.+))?" r"(\*\*\* TURN \*\*\* \[\S\S \S\S \S\S] (?P\[\S\S\].+(?=\*\*\* RIVER \*\*\*)|.+))?" r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P\[\S\S\].+))?", hand.handText,re.DOTALL) - elif hand.gametype['base'] == "stud": # or should this be gametype['category'] == 'razz' + elif hand.gametype['base'] == "stud": m = re.search(r"(?P.+(?=\*\*\* 3RD STREET \*\*\*)|.+)" r"(\*\*\* 3RD STREET \*\*\*(?P.+(?=\*\*\* 4TH STREET \*\*\*)|.+))?" r"(\*\*\* 4TH STREET \*\*\*(?P.+(?=\*\*\* 5TH STREET \*\*\*)|.+))?" r"(\*\*\* 5TH STREET \*\*\*(?P.+(?=\*\*\* 6TH STREET \*\*\*)|.+))?" r"(\*\*\* 6TH STREET \*\*\*(?P.+(?=\*\*\* 7TH STREET \*\*\*)|.+))?" r"(\*\*\* 7TH STREET \*\*\*(?P.+))?", hand.handText,re.DOTALL) + elif hand.gametype['base'] in ("draw"): + m = re.search(r"(?P.+(?=\*\*\* HOLE CARDS \*\*\*)|.+)" + r"(\*\*\* HOLE CARDS \*\*\*(?P.+(?=\*\*\* FIRST DRAW \*\*\*)|.+))?" + r"(\*\*\* FIRST DRAW \*\*\*(?P.+(?=\*\*\* SECOND DRAW \*\*\*)|.+))?" + r"(\*\*\* SECOND DRAW \*\*\*(?P.+(?=\*\*\* THIRD DRAW \*\*\*)|.+))?" + r"(\*\*\* THIRD DRAW \*\*\*(?P.+))?", hand.handText,re.DOTALL) + hand.addStreets(m) def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand diff --git a/pyfpdb/HUD_main.pyw b/pyfpdb/HUD_main.pyw old mode 100644 new mode 100755 index 7d433a1c..7954cda7 --- a/pyfpdb/HUD_main.pyw +++ b/pyfpdb/HUD_main.pyw @@ -131,7 +131,7 @@ class HUD_main(object): self.main_window.set_icon_stock(gtk.STOCK_HOME) self.main_window.show_all() gobject.timeout_add(100, self.check_tables) - + except: log.error("*** Exception in HUD_main.init() *** ") for e in traceback.format_tb(sys.exc_info()[2]): diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 6f0d4890..f99e05f4 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -298,7 +298,7 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py. elif gametype['base'] == 'draw': hand = Hand.DrawHand(self.config, self, self.sitename, gametype, handText) else: - log.info(_("Unsupported game type: %s" % gametype)) + log.error(_("Unsupported game type: %s" % gametype)) raise FpdbParseError(_("Unsupported game type: %s" % gametype)) if hand: diff --git a/pyfpdb/ImapFetcher.py b/pyfpdb/ImapFetcher.py old mode 100755 new mode 100644 index 1d2068d7..ba62673e --- a/pyfpdb/ImapFetcher.py +++ b/pyfpdb/ImapFetcher.py @@ -131,7 +131,7 @@ def readFile(filename, options): return whole_file def runFake(db, config, options): - summaryText = readFile(options.infile, options) + summaryText = readFile(options.filename, options) importSummaries(db, config,[summaryText], options=options) def importSummaries(db, config, summaries, options = None): diff --git a/pyfpdb/Options.py b/pyfpdb/Options.py index 4646cb6e..b8be3d2a 100644 --- a/pyfpdb/Options.py +++ b/pyfpdb/Options.py @@ -38,9 +38,6 @@ def fpdb_options(): parser.add_option("-r", "--rerunPython", action="store_true", help=_("Indicates program was restarted with a different path (only allowed once).")) - parser.add_option("-i", "--infile", - dest="infile", default="Slartibartfast", - help=_("Input file")) parser.add_option("-k", "--konverter", dest="hhc", default="PokerStarsToFpdb", help=_("Module name for Hand History Converter")) diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 24719de5..a6c4d771 100644 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -97,10 +97,11 @@ class PokerStars(HandHistoryConverter): (?P%(LS)s|)? (?P[.0-9]+)/(%(LS)s)? (?P[.0-9]+) + (?P\s-\s[%(LS)s\d\.]+\sCap\s-\s)? # Optional Cap part \s?(?P%(LEGAL_ISO)s)? \)\s-\s # close paren of the stakes - (?P.*$)""" % substitutions, - re.MULTILINE|re.VERBOSE) + (?P.*$) + """ % substitutions, re.MULTILINE|re.VERBOSE) re_PlayerInfo = re.compile(u""" ^Seat\s(?P[0-9]+):\s @@ -146,6 +147,7 @@ class PokerStars(HandHistoryConverter): ^%(PLYR)s:(?P\sbets|\schecks|\sraises|\scalls|\sfolds|\sdiscards|\sstands\spat) (\s(%(CUR)s)?(?P[.\d]+))?(\sto\s%(CUR)s(?P[.\d]+))? # the number discarded goes in \s*(and\sis\sall.in)? + (and\shas\sreached\sthe\s[%(CUR)s\d\.]+\scap)? (\scards?(\s\[(?P.+?)\])?)?\s*$""" % subst, re.MULTILINE|re.VERBOSE) self.re_ShowdownAction = re.compile(r"^%s: shows \[(?P.*)\]" % player_re, re.MULTILINE) diff --git a/pyfpdb/TestHandsPlayers.py b/pyfpdb/TestHandsPlayers.py index 3d072d05..53a2dbd4 100755 --- a/pyfpdb/TestHandsPlayers.py +++ b/pyfpdb/TestHandsPlayers.py @@ -142,6 +142,7 @@ def main(argv=None): BetfairErrors = FpdbError('Betfair') OnGameErrors = FpdbError('OnGame') AbsoluteErrors = FpdbError('Absolute Poker') + UltimateBetErrors = FpdbError('Ultimate Bet') EverleafErrors = FpdbError('Everleaf Poker') CarbonErrors = FpdbError('Carbon') PKRErrors = FpdbError('PKR') @@ -152,7 +153,7 @@ def main(argv=None): PokerStarsErrors, FTPErrors, PartyPokerErrors, BetfairErrors, OnGameErrors, AbsoluteErrors, EverleafErrors, CarbonErrors, PKRErrors, - iPokerErrors, WinamaxErrors + iPokerErrors, WinamaxErrors, UltimateBetErrors, ] sites = { @@ -162,6 +163,7 @@ def main(argv=None): 'Betfair' : True, 'OnGame' : True, 'Absolute' : True, + 'UltimateBet' : True, 'Everleaf' : True, 'Carbon' : True, 'PKR' : False, @@ -184,6 +186,8 @@ def main(argv=None): walk_testfiles("regression-test-files/cash/OnGame/", compare, importer, OnGameErrors, "OnGame") if sites['Absolute'] == True: walk_testfiles("regression-test-files/cash/Absolute/", compare, importer, AbsoluteErrors, "Absolute") + if sites['UltimateBet'] == True: + walk_testfiles("regression-test-files/cash/UltimateBet/", compare, importer, UltimateBetErrors, "Absolute") if sites['Everleaf'] == True: walk_testfiles("regression-test-files/cash/Everleaf/", compare, importer, EverleafErrors, "Everleaf") if sites['Carbon'] == True: diff --git a/pyfpdb/UltimateBetToFpdb.py b/pyfpdb/UltimateBetToFpdb.py deleted file mode 100755 index d21cc9dc..00000000 --- a/pyfpdb/UltimateBetToFpdb.py +++ /dev/null @@ -1,333 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# Copyright 2008-2010 Carl Gherardi -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# 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 General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -######################################################################## - -import L10n -_ = L10n.get_translation() - -import sys -from HandHistoryConverter import * - - -class UltimateBet(HandHistoryConverter): - - # Static regexes - re_GameInfo = re.compile("Stage #(?P[0-9]+):\s+\(?(?PHold\'em|Razz|Seven Card|Omaha|Omaha Hi/Lo|Badugi) (?PNo Limit|Normal|Pot Limit),? \(?(?P\$|)?(?P[.0-9]+)/\$?(?P[.0-9]+)\) - (?P.*$)", re.MULTILINE) - re_SplitHands = re.compile('(\n\n\n+)') - re_HandInfo = re.compile("^Table \'(?P[- a-zA-Z]+)\'(?P.+?$)?", re.MULTILINE) - re_Button = re.compile('Seat #(?P
[ a-zA-Z]+) - \$?(?P[.0-9]+)/\$?(?P[.0-9]+) - (?P.*) - (?P
[0-9]+):(?P[0-9]+) ET - (?P[0-9]+)/(?P[0-9]+)/(?P[0-9]+)Table (?P
[ a-zA-Z]+)\nSeat (?P