#!/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 sys import exceptions import logging # logging has been set up in fpdb.py or HUD_main.py, use their settings: log = logging.getLogger("parser") import Configuration from HandHistoryConverter import * from decimal import Decimal import locale lang=locale.getdefaultlocale()[0][0:2] if lang=="en": def _(string): return string else: import gettext try: trans = gettext.translation("fpdb", localedir="locale", languages=[lang]) trans.install() except IOError: def _(string): return string # OnGame HH Format class OnGame(HandHistoryConverter): filter = "OnGame" filetype = "text" codepage = ("utf8", "cp1252") siteId = 5 # Needs to match id entry in Sites database mixes = { } # Legal mixed games sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\xe2\x82\xac", "GBP": "\xa3"} # ADD Euro, Sterling, etc HERE substitutions = { 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes 'LS' : "\$|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8) } limits = { 'NO_LIMIT':'nl', 'LIMIT':'fl'} games = { # base, category "TEXAS_HOLDEM" : ('hold','holdem'), # 'Omaha' : ('hold','omahahi'), # 'Omaha Hi/Lo' : ('hold','omahahilo'), # 'Razz' : ('stud','razz'), # 'RAZZ' : ('stud','razz'), # '7 Card Stud' : ('stud','studhi'), 'SEVEN_CARD_STUD_HI_LO' : ('stud','studhilo'), # 'Badugi' : ('draw','badugi'), # 'Triple Draw 2-7 Lowball' : ('draw','27_3draw'), # '5 Card Draw' : ('draw','fivedraw') } # Static regexes # ***** End of hand R5-75443872-57 ***** re_SplitHands = re.compile(u'\*\*\*\*\*\sEnd\sof\shand\s[-A-Z\d]+.*\n(?=\*)') # ***** History for hand R5-75443872-57 ***** # Start hand: Wed Aug 18 19:29:10 GMT+0100 2010 # Table: someplace [75443872] (LIMIT TEXAS_HOLDEM 0.50/1, Real money) #***** History for hand R5-78042004-262 ***** #Start hand: Fri Aug 27 21:40:46 GMT+0100 2010 #Table: Bamako [78042004] (LIMIT TEXAS_HOLDEM $0.25/$0.50, Real money) #User: sagi34 #{ u'BB': None #, u'DATETIME': u'Fri Aug 27 22:38:26 GMT+0100 2010\\n' #, u'GAME': None #, u'HID': u'R5-78042004-346' #, u'TABLE': u'Bamako' #, u'LIMIT': None #, u'SB': None #} re_HandInfo = re.compile(u""" \*\*\*\*\*\sHistory\sfor\shand\s(?P[-A-Z\d]+).* Start\shand:\s(?P.*) Table:\s(?P[\'\w\s]+)\s\[\d+\]\s\( ( (?PNO_LIMIT|Limit|LIMIT|Pot\sLimit)\s (?PTEXAS_HOLDEM|RAZZ)\s (%(LS)s)?(?P[.0-9]+)/ (%(LS)s)?(?P[.0-9]+) )? """ % substitutions, re.MULTILINE|re.DOTALL|re.VERBOSE) re_TailSplitHands = re.compile(u'(\*\*\*\*\*\sEnd\sof\shand\s[-A-Z\d]+.*\n)(?=\*)') re_Button = re.compile('Button: seat (?P