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_TourNo
= re
.compile("ID\=(?P<TOURNO>[0-9]+)")
55 re_Player
= re
.compile(u
"""(?P<RANK>\d+)<\/td><td width="30%">(?P<PNAME>.+?)<\/td><td width="60%">(?P<WINNINGS>.+?)</td>""")
57 re_Details
= re
.compile(u
"""<p class="text">(?P<LABEL>.+?) : (?P<VALUE>.+?)</p>""")
58 re_Prizepool
= re
.compile(u
"""<div class="title2">.+: (?P<PRIZEPOOL>[0-9,]+)""")
60 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]+)")
61 re_Ticket
= re
.compile(u
""" / (?P<TTYPE>Ticket (?P<VALUE>[0-9.]+)€|Tremplin Winamax Poker Tour|Starting Block Winamax Poker Tour|Finale Freeroll Mobile 2012|SNG Freeroll Mobile 2012)""")
66 def getSplitRe(self
, head
):
67 re_SplitTourneys
= re
.compile("PokerStars Tournament ")
68 return re_SplitTourneys
70 def parseSummary(self
):
72 soup
= BeautifulSoup(self
.summaryText
)
73 tl
= soup
.findAll('div', {"class":"left_content"})
75 ps
= soup
.findAll('p', {"class": "text"})
77 for m
in self
.re_Details
.finditer(str(p
)):
80 if mg
['LABEL'] == 'Buy-in':
81 mg
['VALUE'] = mg
['VALUE'].replace(u
"€", "")
82 mg
['VALUE'] = mg
['VALUE'].replace(u
"+", "")
83 mg
['VALUE'] = mg
['VALUE'].strip(" $")
84 bi
, fee
= mg
['VALUE'].split(" ")
85 self
.buyin
= int(100*Decimal(bi
))
86 self
.fee
= int(100*Decimal(fee
))
87 #print "DEBUG: bi: '%s' fee: '%s" % (self.buyin, self.fee)
88 if mg
['LABEL'] == 'Nombre de joueurs inscrits':
89 self
.entries
= mg
['VALUE']
90 if mg
['LABEL'] == 'D\xc3\xa9but du tournoi':
91 self
.startTime
= datetime
.datetime
.strptime(mg
['VALUE'], "%d-%m-%Y %H:%M")
92 if mg
['LABEL'] == 'Nombre de joueurs max':
96 div
= soup
.findAll('div', {"class": "title2"})
97 for m
in self
.re_Prizepool
.finditer(str(div
)):
100 self
.prizepool
= mg
['PRIZEPOOL'].replace(u
',','.')
103 for m
in self
.re_GameType
.finditer(str(tl
[0])):
106 self
.gametype
['limitType'] = self
.limits
[mg
['LIMIT']]
107 self
.gametype
['category'] = self
.games
[mg
['GAME']][1]
110 # Quitte or Double, Starting Block Winamax Poker Tour
111 # Do not contain enough the gametype.
112 # Lookup the tid from the db, if it exists get the gametype info from there, otherwise ParseError
113 log
.warning(_("WinamaxSummary.parseSummary: Gametype unknown defaulting to NLHE"))
114 self
.gametype
['limitType'] = 'nl'
115 self
.gametype
['category'] = 'holdem'
117 for m
in self
.re_Player
.finditer(str(tl
[0])):
122 #print "DEUBG: mg: '%s'" % mg
123 is_satellite
= self
.re_Ticket
.search(mg
['WINNINGS'])
126 if is_satellite
.group('VALUE'):
127 winnings
= convert_to_decimal(is_satellite
.group('VALUE'))
128 else: # Value not specified
130 # FIXME: Do lookup here
131 # Tremplin Winamax Poker Tour
132 # Starting Block Winamax Poker Tour
134 # For stallites, any ticket means 1st
138 winnings
= convert_to_decimal(mg
['WINNINGS'])
140 winnings
= int(100*Decimal(winnings
))
141 #print "DEBUG: %s) %s: %s" %(rank, name, winnings)
142 self
.addPlayer(rank
, name
, winnings
, self
.currency
, None, None, None)
145 for m
in self
.re_TourNo
.finditer(self
.summaryText
):
148 self
.tourNo
= mg
['TOURNO']
150 def convert_to_decimal(string
):
151 dec
= string
.strip(u
'€€\u20ac')
152 dec
= dec
.replace(u
',','.')
153 dec
= dec
.replace(u
' ','')