Carbon Poker offers a 5 card stud game that wasn't listed here. It's not available...
[fpdb-dooglus.git] / pyfpdb / WinamaxSummary.py
blob3d001308a0f5d649b2a3d517a4ce2c7ee0b2557c
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 #Copyright 2008-2011 Carl Gherardi
5 #This program is free software: you can redistribute it and/or modify
6 #it under the terms of the GNU Affero General Public License as published by
7 #the Free Software Foundation, version 3 of the License.
9 #This program is distributed in the hope that it will be useful,
10 #but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 #GNU General Public License for more details.
14 #You should have received a copy of the GNU Affero General Public License
15 #along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #In the "official" distribution you can find the license in agpl-3.0.txt.
18 import L10n
19 _ = L10n.get_translation()
21 from decimal_wrapper import Decimal
22 import datetime
23 from BeautifulSoup import BeautifulSoup
25 from Exceptions import FpdbParseError
26 from HandHistoryConverter import *
27 import PokerStarsToFpdb
28 from TourneySummary import *
31 class WinamaxSummary(TourneySummary):
32 limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl', 'LIMIT':'fl' }
33 games = { # base, category
34 "Hold'em" : ('hold','holdem'),
35 'Omaha' : ('hold','omahahi'),
36 'Omaha Hi/Lo' : ('hold','omahahilo'),
37 'Razz' : ('stud','razz'),
38 'RAZZ' : ('stud','razz'),
39 '7 Card Stud' : ('stud','studhi'),
40 '7 Card Stud Hi/Lo' : ('stud','studhilo'),
41 'Badugi' : ('draw','badugi'),
42 'Triple Draw 2-7 Lowball' : ('draw','27_3draw'),
43 '5 Card Draw' : ('draw','fivedraw')
46 substitutions = {
47 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes
48 'LS' : u"\$|\xe2\x82\xac|\u20ac|" # legal currency symbols
51 re_GameType = re.compile("""<h1>((?P<LIMIT>No Limit|Pot Limit) (?P<GAME>Hold\'em))</h1>""")
53 re_SplitTourneys = re.compile("PokerStars Tournament ")
55 re_TourNo = re.compile("ID\=(?P<TOURNO>[0-9]+)")
57 re_Player = re.compile(u"""(?P<RANK>\d+)<\/td><td width="30%">(?P<PNAME>.+?)<\/td><td width="60%">(?P<WINNINGS>.+?)</td>""")
59 re_Details = re.compile(u"""<p class="text">(?P<LABEL>.+?) : (?P<VALUE>.+?)</p>""")
60 re_Prizepool = re.compile(u"""<div class="title2">.+: (?P<PRIZEPOOL>[0-9,]+)""")
62 re_DateTime = re.compile("\[(?P<Y>[0-9]{4})\/(?P<M>[0-9]{2})\/(?P<D>[0-9]{2})[\- ]+(?P<H>[0-9]+):(?P<MIN>[0-9]+):(?P<S>[0-9]+)")
63 re_Ticket = re.compile(u""" / Ticket (?P<VALUE>[0-9.]+)&euro;""")
65 codepage = ["utf-8"]
67 def parseSummary(self):
68 self.currency = "EUR"
69 soup = BeautifulSoup(self.summaryText)
70 tl = soup.findAll('div', {"class":"left_content"})
72 ps = soup.findAll('p', {"class": "text"})
73 for p in ps:
74 for m in self.re_Details.finditer(str(p)):
75 mg = m.groupdict()
76 #print mg
77 if mg['LABEL'] == 'Buy-in':
78 mg['VALUE'] = mg['VALUE'].replace(u"&euro;", "")
79 mg['VALUE'] = mg['VALUE'].replace(u"+", "")
80 mg['VALUE'] = mg['VALUE'].strip(" $")
81 bi, fee = mg['VALUE'].split(" ")
82 self.buyin = int(100*Decimal(bi))
83 self.fee = int(100*Decimal(fee))
84 #print "DEBUG: bi: '%s' fee: '%s" % (self.buyin, self.fee)
85 if mg['LABEL'] == 'Nombre de joueurs inscrits':
86 self.entries = mg['VALUE']
87 if mg['LABEL'] == 'D\xc3\xa9but du tournoi':
88 self.startTime = datetime.datetime.strptime(mg['VALUE'], "%d-%m-%Y %H:%M")
89 if mg['LABEL'] == 'Nombre de joueurs max':
90 # Max seats i think
91 pass
93 div = soup.findAll('div', {"class": "title2"})
94 for m in self.re_Prizepool.finditer(str(div)):
95 mg = m.groupdict()
96 #print mg
97 self.prizepool = mg['PRIZEPOOL'].replace(u',','.')
100 for m in self.re_GameType.finditer(str(tl[0])):
101 mg = m.groupdict()
102 #print mg
103 self.gametype['limitType'] = self.limits[mg['LIMIT']]
104 self.gametype['category'] = self.games[mg['GAME']][1]
106 for m in self.re_Player.finditer(str(tl[0])):
107 winnings = 0
108 mg = m.groupdict()
109 rank = mg['RANK']
110 name = mg['PNAME']
111 #print "DEUBG: mg: '%s'" % mg
112 is_satellite = self.re_Ticket.search(mg['WINNINGS'])
113 if is_satellite:
114 # Ticket
115 winnings = convert_to_decimal(is_satellite.groupdict()['VALUE'])
116 # For stallites, any ticket means 1st
117 if winnings > 0:
118 rank = 1
119 else:
120 winnings = convert_to_decimal(mg['WINNINGS'])
122 winnings = int(100*Decimal(winnings))
123 #print "DEBUG: %s) %s: %s" %(rank, name, winnings)
124 self.addPlayer(rank, name, winnings, self.currency, None, None, None)
127 for m in self.re_TourNo.finditer(self.summaryText):
128 mg = m.groupdict()
129 #print mg
130 self.tourNo = mg['TOURNO']
132 def convert_to_decimal(string):
133 dec = string.strip(u'€&euro;\u20ac')
134 dec = dec.replace(u',','.')
135 dec = dec.replace(u' ','')
136 dec = Decimal(dec)
137 return dec