#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2008, 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 ######################################################################## # TODO: straighten out discards for draw games import sys from HandHistoryConverter import * # PokerStars HH Format class PokerStars(HandHistoryConverter): # Class Variables sitename = "PokerStars" filetype = "text" codepage = ("utf8", "cp1252") siteId = 2 # Needs to match id entry in Sites database mixes = { 'HORSE': 'horse', '8-Game': '8game', 'HOSE': 'hose'} # 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) } # Static regexes re_GameInfo = re.compile(u""" PokerStars\sGame\s\#(?P[0-9]+):\s+ (Tournament\s\# # open paren of tournament info (?P\d+),\s # here's how I plan to use LS (?P([%(LS)s\+\d\.]+\s?(?P%(LEGAL_ISO)s)?)|Freeroll)\s+)? # close paren of tournament info (?PHORSE|8\-Game|HOSE)?\s?\(? (?PHold\'em|Razz|RAZZ|7\sCard\sStud|7\sCard\sStud\sHi/Lo|Omaha|Omaha\sHi/Lo|Badugi|Triple\sDraw\s2\-7\sLowball|5\sCard\sDraw)\s (?PNo\sLimit|Limit|LIMIT|Pot\sLimit)\)?,?\s (-\sLevel\s(?P[IVXLC]+)\s)? \(? # open paren of the stakes (?P%(LS)s|)? (?P[.0-9]+)/(%(LS)s)? (?P[.0-9]+) \s?(?P%(LEGAL_ISO)s)? \)\s-\s # close paren of the stakes (?P.*$)""" % substitutions, re.MULTILINE|re.VERBOSE) re_PlayerInfo = re.compile(u""" ^Seat\s(?P[0-9]+):\s (?P.*)\s \((%(LS)s)?(?P[.0-9]+)\sin\schips\)""" % substitutions, re.MULTILINE|re.VERBOSE) re_HandInfo = re.compile(""" ^Table\s\'(?P[-\ \#a-zA-Z\d]+)\'\s ((?P\d+)-max\s)? (?P\(Play\sMoney\)\s)? (Seat\s\#(?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