#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2009-2011, Grigorij Indigirkin # # 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 collections import defaultdict from Configuration import LOCALE_ENCODING from Exceptions import FpdbParseError from HandHistoryConverter import * # PartyPoker HH Format class FpdbParseError(FpdbParseError): "Usage: raise FpdbParseError([, hh=][, hid=])" def __init__(self, msg='', hh=None, hid=None): return super(FpdbParseError, self).__init__(msg, hid=hid) def wrapHh(self, hh): return ("%(DELIMETER)s\n%(HH)s\n%(DELIMETER)s") % \ {'DELIMETER': '#'*50, 'HH': hh} class PartyPoker(HandHistoryConverter): sitename = "PartyPoker" codepage = "utf8" siteId = 9 filetype = "text" sym = {'USD': "\$", 'EUR': u"\u20ac", 'T$': ""} currencies = {"\$": "USD", "$": "USD", u"\xe2\x82\xac": "EUR", u"\u20ac": "EUR", '': "T$"} substitutions = { 'LEGAL_ISO' : "USD|EUR", # legal ISO currency codes 'LS' : u"\$|\u20ac|\xe2\x82\xac|", # Currency symbols - Euro(cp1252, utf-8) 'NUM' : u".,\d", } # Static regexes # $5 USD NL Texas Hold'em - Saturday, July 25, 07:53:52 EDT 2009 # NL Texas Hold'em $1 USD Buy-in Trny:45685440 Level:8 Blinds-Antes(600/1 200 -50) - Sunday, May 17, 11:25:07 MSKS 2009 re_GameInfoRing = re.compile(u""" (?P[%(LS)s])\s*(?P[.,0-9]+)([.,0-9/$]+)?\s*(?:%(LEGAL_ISO)s)?\s* (?P(NL|PL|))\s* (?P(Texas\ Hold\'em|Omaha|7\ Card\ Stud\ Hi-Lo)) \s*\-\s* (?P.+) """ % substitutions, re.VERBOSE | re.UNICODE) re_GameInfoTrny = re.compile(""" (?P(NL|PL|))\s* (?P(Texas\ Hold\'em|Omaha))\s+ (?:(?P\$?[.,0-9]+)\s*(?P%(LEGAL_ISO)s)?\s*Buy-in\s+)? Trny:\s?(?P\d+)\s+ Level:\s*(?P\d+)\s+ ((Blinds|Stakes)(?:-Antes)?)\( (?P[.,0-9 ]+)\s* /(?P[.,0-9 ]+) (?:\s*-\s*(?P[.,0-9 ]+)\$?)? \) \s*\-\s* (?P.+) """ % substitutions, re.VERBOSE | re.UNICODE) re_Hid = re.compile("Game \#(?P\d+) starts.") re_PlayerInfo = re.compile(u""" Seat\s(?P\d+):\s (?P.*)\s \(\s*[%(LS)s]?(?P[%(NUM)s]+)\s*(?:%(LEGAL_ISO)s|)\s*\) """ % substitutions, re.VERBOSE| re.UNICODE) re_HandInfo = re.compile(""" ^Table\s+(?P[$a-zA-Z0-9 ]+)?\s+ (?: \#|\(|)(?P\d+)\)?\s+ (?:[a-zA-Z0-9 ]+\s+\#(?P\d+).+)? (\(No\sDP\)\s)? \((?PReal|Play)\s+Money\)\s+ # FIXME: check if play money is correct Seat\s+(?P