From 4a7a24eb68948dbb7392bda1edbdd63627062b64 Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 11 Feb 2011 17:50:45 +0800 Subject: [PATCH] WinamaxSummary: Add initial parser for Winamax Summary files --- pyfpdb/WinamaxSummary.py | 119 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 pyfpdb/WinamaxSummary.py diff --git a/pyfpdb/WinamaxSummary.py b/pyfpdb/WinamaxSummary.py new file mode 100644 index 00000000..c3a5bd14 --- /dev/null +++ b/pyfpdb/WinamaxSummary.py @@ -0,0 +1,119 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +#Copyright 2008-2011 Carl Gherardi +#This program is free software: you can redistribute it and/or modify +#it under the terms of the GNU Affero General Public License as published by +#the Free Software Foundation, version 3 of the License. +# +#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 Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in agpl-3.0.txt. + +import L10n +_ = L10n.get_translation() + +from decimal import Decimal +import datetime +from BeautifulSoup import BeautifulSoup + +from Exceptions import FpdbParseError +from HandHistoryConverter import * +import PokerStarsToFpdb +from TourneySummary import * + + +class WinamaxSummary(TourneySummary): + limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl', 'LIMIT':'fl' } + games = { # base, category + "Hold'em" : ('hold','holdem'), + 'Omaha' : ('hold','omahahi'), + 'Omaha Hi/Lo' : ('hold','omahahilo'), + 'Razz' : ('stud','razz'), + 'RAZZ' : ('stud','razz'), + '7 Card Stud' : ('stud','studhi'), + '7 Card Stud Hi/Lo' : ('stud','studhilo'), + 'Badugi' : ('draw','badugi'), + 'Triple Draw 2-7 Lowball' : ('draw','27_3draw'), + '5 Card Draw' : ('draw','fivedraw') + } + + substitutions = { + 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes + 'LS' : u"\$|\xe2\x82\xac|\u20AC|" # legal currency symbols + } + + re_GameType = re.compile("""

((?PNo Limit|Pot Limit) (?PHold\'em))

""") + + re_SplitTourneys = re.compile("PokerStars Tournament ") + + re_TourNo = re.compile("ID\=(?P[0-9]+)") + + re_Player = re.compile(u"""(?P\d+)<\/td>(?P.+?)<\/td>(?P.+?)""") + + re_Details = re.compile(u"""

(?P

""") + re_Prizepool = re.compile(u"""
.+: (?P[0-9,]+)""") + + re_DateTime = re.compile("\[(?P[0-9]{4})\/(?P[0-9]{2})\/(?P[0-9]{2})[\- ]+(?P[0-9]+):(?P[0-9]+):(?P[0-9]+)") + + codepage = ["utf-8"] + + def parseSummary(self): + self.currency = "EUR" + soup = BeautifulSoup(self.summaryText) + tl = soup.findAll('div', {"class":"left_content"}) + + ps = soup.findAll('p', {"class": "text"}) + for p in ps: + for m in self.re_Details.finditer(str(p)): + mg = m.groupdict() + #print mg + if mg['LABEL'] == 'Buy-in': + mg['VALUE'] = mg['VALUE'].replace(u"€", "") + mg['VALUE'] = mg['VALUE'].replace(u"+", "") + mg['VALUE'] = mg['VALUE'].strip(" $") + bi, fee = mg['VALUE'].split(" ") + self.buyin = int(100*Decimal(bi)) + self.fee = int(100*Decimal(fee)) + #print "DEBUG: bi: '%s' fee: '%s" % (self.buyin, self.fee) + if mg['LABEL'] == 'Nombre de joueurs inscrits': + self.entries = mg['VALUE'] + if mg['LABEL'] == 'D\xc3\xa9but du tournoi': + self.startTime = datetime.datetime.strptime(mg['VALUE'], "%d-%m-%Y %H:%M") + if mg['LABEL'] == 'Nombre de joueurs max': + # Max seats i think + pass + + div = soup.findAll('div', {"class": "title2"}) + for m in self.re_Prizepool.finditer(str(div)): + mg = m.groupdict() + #print mg + self.prizepool = mg['PRIZEPOOL'].replace(u',','.') + + + for m in self.re_GameType.finditer(str(tl[0])): + mg = m.groupdict() + #print mg + self.gametype['limitType'] = self.limits[mg['LIMIT']] + self.gametype['category'] = self.games[mg['GAME']][1] + + for m in self.re_Player.finditer(str(tl[0])): + mg = m.groupdict() + #print mg + winnings = mg['WINNINGS'].strip(u'€').replace(u',','.') + winnings = int(100*Decimal(winnings)) + rank = mg['RANK'] + name = mg['PNAME'] + #print "DEBUG: %s: %s" %(name, winnings) + self.addPlayer(rank, name, winnings, self.currency, None, None, None) + + + for m in self.re_TourNo.finditer(self.summaryText): + mg = m.groupdict() + #print mg + self.tourNo = mg['TOURNO']