When there are an odd number of limits to display in the Limits filter, put more...
[fpdb-dooglus.git] / pyfpdb / SitenameSummary.py
blob8e33cc6502f745067ec74bb10003152695dfc617
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 #Copyright 2008-2011 Steffen Schaumburg
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 """A site template for tourney summary parsing"""
20 import L10n
21 _ = L10n.get_translation()
23 from decimal_wrapper import Decimal
24 import datetime
26 from Exceptions import FpdbParseError
27 from HandHistoryConverter import *
28 import PokerStarsToFpdb
29 from TourneySummary import *
31 class Sitename(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_SplitTourneys = re.compile("PokerStars Tournament ")
53 re_TourNo = re.compile("\#(?P<TOURNO>[0-9]+),")
55 re_TourneyInfo = re.compile(u"""
56 \#(?P<TOURNO>[0-9]+),\s
57 (?P<LIMIT>No\sLimit|Limit|LIMIT|Pot\sLimit)\s
58 (?P<GAME>Hold\'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+
59 (?P<DESC>[ a-zA-Z]+\s+)?
60 (Buy-In:\s[%(LS)s](?P<BUYIN>[.0-9]+)(\/[%(LS)s](?P<FEE>[.0-9]+))?(?P<CUR>\s(%(LEGAL_ISO)s))?\s+)?
61 (?P<ENTRIES>[0-9]+)\splayers\s+
62 ([%(LS)s]?(?P<ADDED>[.\d]+)\sadded\sto\sthe\sprize\spool\sby\sPokerStars\.com\s+)?
63 (Total\sPrize\sPool:\s[%(LS)s]?(?P<PRIZEPOOL>[.0-9]+)(\s(%(LEGAL_ISO)s))?\s+)?
64 (Target\sTournament\s.*)?
65 Tournament\sstarted\s+(-\s)?
66 (?P<Y>[0-9]{4})\/(?P<M>[0-9]{2})\/(?P<D>[0-9]{2})[\-\s]+(?P<H>[0-9]+):(?P<MIN>[0-9]+):(?P<S>[0-9]+)\s?\(?(?P<TZ>[A-Z]+)\)?\s
67 """ % substitutions ,re.VERBOSE|re.MULTILINE|re.DOTALL)
69 re_Currency = re.compile(u"""(?P<CURRENCY>[%(LS)s]|FPP)""" % substitutions)
71 re_Player = re.compile(u"""(?P<RANK>[0-9]+):\s(?P<NAME>.*)\s\(.*\),(\s)?(\$(?P<WINNINGS>[0-9]+\.[0-9]+))?(?P<STILLPLAYING>still\splaying)?((?P<TICKET>Tournament\sTicket)\s\(WSOP\sStep\s(?P<LEVEL>\d)\))?(\s+)?""")
73 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]+)")
75 codepage = ["utf-8"]
77 def parseSummary(self):
78 m = self.re_TourneyInfo.search(self.summaryText)
79 if m == None:
80 tmp = self.summaryText[0:200]
81 log.error("parseSummary: " + _("Unable to recognise Tourney Info: '%s'") % tmp)
82 log.error("parseSummary: " + _("Raising FpdbParseError"))
83 raise FpdbParseError(_("Unable to recognise Tourney Info: '%s'") % tmp)
85 print "DEBUG: m.groupdict(): %s" % m.groupdict()
87 mg = m.groupdict()
88 self.tourNo = ''
89 self.gametype['limitType'] = ''
90 self.gametype['category'] = ''
91 self.buyin = 0
92 self.fee = 0
93 self.prizepool = 0
94 self.entries = 0
95 #self.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S")
97 self.currency = "USD"
99 #self.addPlayer(rank, name, winnings, self.currency, None, None, None)