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.
19 _
= L10n
.get_translation()
21 from decimal_wrapper
import Decimal
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')
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.]+)€""")
67 def parseSummary(self
):
69 soup
= BeautifulSoup(self
.summaryText
)
70 tl
= soup
.findAll('div', {"class":"left_content"})
72 ps
= soup
.findAll('p', {"class": "text"})
74 for m
in self
.re_Details
.finditer(str(p
)):
77 if mg
['LABEL'] == 'Buy-in':
78 mg
['VALUE'] = mg
['VALUE'].replace(u
"€", "")
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':
93 div
= soup
.findAll('div', {"class": "title2"})
94 for m
in self
.re_Prizepool
.finditer(str(div
)):
97 self
.prizepool
= mg
['PRIZEPOOL'].replace(u
',','.')
100 for m
in self
.re_GameType
.finditer(str(tl
[0])):
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])):
111 #print "DEUBG: mg: '%s'" % mg
112 is_satellite
= self
.re_Ticket
.search(mg
['WINNINGS'])
115 winnings
= convert_to_decimal(is_satellite
.groupdict()['VALUE'])
116 # For stallites, any ticket means 1st
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
):
130 self
.tourNo
= mg
['TOURNO']
132 def convert_to_decimal(string
):
133 dec
= string
.strip(u
'€€\u20ac')
134 dec
= dec
.replace(u
',','.')
135 dec
= dec
.replace(u
' ','')