Coverage for PacificPokerSummary.py: 0%
86 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-28 16:41 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-28 16:41 +0000
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
4#Copyright 2008-2012 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.
8#
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.
13#
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()
21from decimal_wrapper import Decimal
22import datetime
24from Exceptions import FpdbParseError
25from HandHistoryConverter import *
26import PacificPokerToFpdb
27from TourneySummary import *
29class PacificPokerSummary(TourneySummary):
31 limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl', 'LIMIT':'fl' }
33 games = { # base, category
34 "Hold'em" : ('hold','holdem'),
35 'Holdem' : ('hold','holdem'),
36 'Omaha' : ('hold','omahahi'),
37 'Omaha Hi/Lo' : ('hold','omahahilo'),
38 'OmahaHL' : ('hold','omahahilo')
39 }
41 substitutions = {
42 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes
43 'LS' : u"\$|€|", # legal currency symbols
44 'NUM' : u".,\d\xa0" # legal characters in number format
45 }
47 re_Identify = re.compile(u'\*{5}\s(Cassava|888poker|888)(\.[a-z]{2})?(\-[a-z]{2})? Tournament Summary\s\*{5}')
49 re_TourneyInfo = re.compile(u"""
50 Tournament\sID:\s(?P<TOURNO>[0-9]+)\s+
51 Buy-In:\s(?P<BUYIN>(((?P<BIAMT>(?P<CURRENCY1>%(LS)s)?[%(NUM)s]+\s?(?P<CURRENCY2>%(LS)s)?)(\s\+\s?(?P<BIRAKE>(%(LS)s)?[%(NUM)s]+\s?(%(LS)s)?))?)|(Free)|(.+?)))\s+
52 (Rebuy:\s[%(LS)s](?P<REBUYAMT>[%(NUM)s]+)\s?(%(LS)s)?\s+)?
53 (Add-On:\s[%(LS)s](?P<ADDON>[%(NUM)s]+)\s?(%(LS)s)?\s+)?
54 ((?P<P1NAME>.*?)\sperformed\s(?P<PREBUYS>\d+)\srebuys?\s+)?
55 ((?P<P2NAME>.*?)\sperformed\s(?P<PADDONS>\d+)\sadd-ons?\s+)?
56 ^(?P<PNAME>.+?)\sfinished\s(?P<RANK>[0-9]+)\/(?P<ENTRIES>[0-9]+)(\sand\swon\s(?P<WCURRENCY>[%(LS)s])?(?P<WINNINGS>[%(NUM)s]+)\s?(?P<WCURRENCY2>[%(LS)s])?)?
57 """ % substitutions ,re.VERBOSE|re.MULTILINE|re.DOTALL)
59 re_Category = re.compile(u"""
60 (?P<LIMIT>No\sLimit|Fix\sLimit|Pot\sLimit)\s
61 (?P<GAME>Holdem|Omaha|OmahaHL|Hold\'em|Omaha\sHi/Lo|OmahaHL)
62 """ % substitutions ,re.VERBOSE|re.MULTILINE|re.DOTALL)
64 codepage = ("utf8", "cp1252")
66 @staticmethod
67 def getSplitRe(self, head):
68 re_SplitTourneys = re.compile(u'\*\*\*\*\* (Cassava|888poker|888)(\.[a-z]{2})?(\-[a-z]{2})? Tournament Summary \*\*\*\*\*')
69 return re_SplitTourneys
71 def parseSummary(self):
72 m = self.re_TourneyInfo.search(self.summaryText)
73 if m == None:
74 tmp = self.summaryText[0:200]
75 log.error(("PacificPokerSummary.parseSummary: '%s'") % tmp)
76 raise FpdbParseError
78 mg = m.groupdict()
79 #print "DEBUG: m.groupdict(): %s" % mg
80 #print "DEBUG: m1.groupdict(): %s" % mg1
82 self.tourNo = mg['TOURNO']
84 m1 = self.re_Category.search(self.in_path)
85 if m1:
86 mg1 = m1.groupdict()
87 if 'LIMIT' in mg1 and mg1['LIMIT'] is not None:
88 self.gametype['limitType'] = self.limits[mg1['LIMIT']]
89 else:
90 self.gametype['limitType'] = 'fl'
91 if 'GAME' in mg1: self.gametype['category'] = self.games[mg1['GAME']][1]
92 else:
93 self.gametype['limitType'] = 'nl'
94 self.gametype['category'] = 'holdem'
96 if 'BUYIN' in mg and mg['BUYIN'] is not None:
97 if mg['BUYIN'] == 'Free' or mg['BIAMT'] is None:
98 self.buyin = 0
99 self.fee = 0
100 else:
101 self.buyin = int(100*self.convert_to_decimal(mg['BIAMT']))
102 if mg['BIRAKE'] is None:
103 self.fee = 0
104 else:
105 self.fee = int(100*self.convert_to_decimal(mg['BIRAKE']))
107 self.entries = mg['ENTRIES']
108 self.prizepool = self.buyin * int(self.entries)
109 if 'REBUYAMT' in mg and mg['REBUYAMT'] != None:
110 self.isRebuy = True
111 self.rebuyCost = int(100*self.convert_to_decimal(mg['REBUYAMT']))
112 if 'ADDON' in mg and mg['ADDON'] != None:
113 self.isAddOn = True
114 self.addOnCost = int(100*self.convert_to_decimal(mg['ADDON']))
115 #self.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S")
117 if 'CURRENCY1' in mg and mg['CURRENCY1']:
118 currency = mg['CURRENCY1']
119 elif 'CURRENCY2' in mg and mg['CURRENCY2']:
120 currency = mg['CURRENCY2']
121 else:
122 currency = None
124 if currency:
125 if currency == "$": self.buyinCurrency="USD"
126 elif currency == u"€": self.buyinCurrency="EUR"
127 elif self.buyin == 0:
128 self.buyinCurrency="FREE"
129 else:
130 self.buyinCurrency="play"
131 self.currency = self.buyinCurrency
133 player = mg['PNAME']
134 rank = int(mg['RANK'])
135 winnings = 0
136 rebuyCount = None
137 addOnCount = None
138 koCount = None
140 if 'WINNINGS' in mg and mg['WINNINGS'] != None:
141 winnings = int(100*self.convert_to_decimal(mg['WINNINGS']))
142 if mg.get('WCURRENCY'):
143 if mg['WCURRENCY'] == "$": self.currency="USD"
144 elif mg['WCURRENCY'] == u"€": self.currency="EUR"
145 elif mg.get('WCURRENCY2'):
146 if mg['WCURRENCY2'] == "$": self.currency="USD"
147 elif mg['WCURRENCY2'] == u"€": self.currency="EUR"
148 if 'PREBUYS' in mg and mg['PREBUYS'] != None:
149 rebuyCount = int(mg['PREBUYS'])
150 if 'PADDONS' in mg and mg['PADDONS'] != None:
151 addOnCount = int(mg['PADDONS'])
153 self.addPlayer(rank, player, winnings, self.currency, rebuyCount, addOnCount, koCount)
155 def convert_to_decimal(self, string):
156 dec = self.clearMoneyString(string)
157 dec = Decimal(dec)
158 return dec