def readHandInfo(self, hand):
        info, m = {}, None
        if self.sitename in ('iPoker', 'Merge'):
            m3 = self.re_Tournament.search(hand.handText,re.DOTALL)
            if m3:
                m  = self.re_HandInfo_Tour.search(hand.handText,re.DOTALL)
            else:
                m  = self.re_HandInfo_Cash.search(hand.handText,re.DOTALL)
            m2 = self.re_GameInfo1.search(hand.handText)
        elif self.sitename=='Everest':
            m2 = self.re_GameInfo2.search(hand.handText)
        elif self.sitename=='Microgaming':
            m2 = self.re_GameInfo3.search(hand.handText)
        if (m is None and self.sitename not in ('Everest', 'Microgaming')) or m2 is None:
            tmp = hand.handText[0:200]
            log.error(_("PokerTrackerToFpdb.readHandInfo: '%s'") % tmp)
            raise FpdbParseError
        
        if self.sitename not in ('Everest', 'Microgaming'):
            info.update(m.groupdict())
        info.update(m2.groupdict())
        
        if self.sitename != 'Everest':
            hand.setUncalledBets(True)

        #print 'readHandInfo', info
        for key in info:
            if key == 'DATETIME':
                #2008/11/12 10:00:48 CET [2008/11/12 4:00:48 ET] # (both dates are parsed so ET date overrides the other)
                #2008/08/17 - 01:14:43 (ET)
                #2008/09/07 06:23:14 ET
                if self.sitename in ('iPoker', 'Microgaming'):
                    m1 = self.re_DateTime1.finditer(info[key])
                elif self.sitename == 'Merge':
                    m1 = self.re_DateTime2.finditer(info[key])
                elif self.sitename == 'Everest':
                    m1 = self.re_DateTime3.finditer(info[key])
                datetimestr = "2000/01/01 00:00:00"  # default used if time not found
                for a in m1:
                    datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'), a.group('M'),a.group('D'),a.group('H'),a.group('MIN'),a.group('S'))
                    #tz = a.group('TZ')  # just assume ET??
                    #print "   tz = ", tz, " datetime =", datetimestr
                hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"
                hand.startTime = HandHistoryConverter.changeTimezone(hand.startTime, "ET", "UTC")
            if key == 'HID':
                if self.sitename == 'Merge':
                    hand.handid = info[key][:8] + info[key][9:]
                else:
                    hand.handid = info[key]
            if key == 'TOURNO':
                hand.tourNo = info[key]
            if key == 'BUYIN':
                if hand.tourNo!=None:
                    tourneyname = ''
                    if self.sitename == 'Merge':
                        if self.Structures is None:
                            self.Structures = MergeStructures.MergeStructures()
                        tourneyname = re.split(",", m.group('TABLE'))[0].strip()
                        structure = self.Structures.lookupSnG(tourneyname, hand.startTime)
                        if structure!=None:
                            hand.buyin = int(100*structure['buyIn'])
                            hand.fee   = int(100*structure['fee'])
                            hand.buyinCurrency=structure['currency']
                            hand.maxseats = structure['seats']
                            hand.isSng = True
                        else:
                            #print 'DEBUG', 'no match for tourney %s tourNo %s' % (tourneyname, hand.tourNo)
                            hand.buyin = 0
                            hand.fee = 0
                            hand.buyinCurrency="NA"
                            hand.maxseats = None
                    if self.sitename != 'Merge' or hand.buyin==0:
                        if info[key] == 'Freeroll' or 'Free' in tourneyname:
                            hand.buyin = 0
                            hand.fee = 0
                            hand.buyinCurrency = "FREE"
                        else:
                            if info[key].find("$")!=-1:
                                hand.buyinCurrency="USD"
                            elif info[key].find(u"£")!=-1:
                                hand.buyinCurrency="GBP"
                            elif info[key].find(u"€")!=-1:
                                hand.buyinCurrency="EUR"
                            elif re.match("^[0-9+]*$", info[key]):
                                hand.buyinCurrency="play"
                            else:
                                #FIXME: handle other currencies, play money
                                log.error(_("PokerTrackerToFpdb.readHandInfo: Failed to detect currency.") + " Hand ID: %s: '%s'" % (hand.handid, info[key]))
                                raise FpdbParseError
    
                            info['BIAMT'] = info['BIAMT'].strip(u'$€£')
                            info['BIRAKE'] = info['BIRAKE'].strip(u'$€£')
    
                            hand.buyin = int(100*Decimal(info['BIAMT']))
                            hand.fee = int(100*Decimal(info['BIRAKE']))
            if key == 'TABLE':
                if hand.gametype['type'] == 'tour':
                    hand.tablename = '0'
                else:
                    hand.tablename = re.split(",", info[key])[0]
                    hand.tablename = hand.tablename.strip()
            if key == 'BUTTON':
                hand.buttonpos = info[key]
            if key == 'MAX' and info[key] != None:
                seats = int(info[key])
                if seats <=10:
                    hand.maxseats = int(info[key])

            if key == 'PLAY' and info['PLAY'] is not None:
#                hand.currency = 'play' # overrides previously set value
                hand.gametype['currency'] = 'play'
                
        if self.re_Cancelled.search(hand.handText):
            raise FpdbHandPartial(_("Hand '%s' was cancelled.") % hand.handid)
 def readBlinds(self, hand):
     liveBlind = True
     for a in self.re_PostSB.finditer(hand.handText):
         sb = self.clearMoneyString(a.group('SB'))
         if liveBlind:
             self.adjustMergeTourneyStack(hand, a.group('PNAME'), a.group('SB'))
             hand.addBlind(a.group('PNAME'), 'small blind', sb)
             if not hand.gametype['sb']:
                 hand.gametype['sb'] = sb
             liveBlind = False
         elif hand.gametype['type'] == 'tour':
             self.adjustMergeTourneyStack(hand, a.group('PNAME'), a.group('SB'))
             if not hand.gametype['bb']:
                 hand.gametype['bb'] = sb
                 hand.addBlind(a.group('PNAME'), 'big blind', sb)
         else:
             # Post dead blinds as ante
             self.adjustMergeTourneyStack(hand, a.group('PNAME'), a.group('SB'))
             hand.addBlind(a.group('PNAME'), 'secondsb', sb)
     for a in self.re_PostBB.finditer(hand.handText):
         bb = self.clearMoneyString(a.group('BB'))
         self.adjustMergeTourneyStack(hand, a.group('PNAME'), a.group('BB'))
         if not hand.gametype['bb']:
             hand.gametype['bb'] = bb
             hand.addBlind(a.group('PNAME'), 'big blind', bb)
         else:
             both = Decimal(hand.gametype['bb']) + Decimal(hand.gametype['bb'])/2
             if both == Decimal(a.group('BB')):
                 hand.addBlind(a.group('PNAME'), 'both', bb)
             else:
                 hand.addBlind(a.group('PNAME'), 'big blind', bb)
                 
     if self.sitename == 'Microgaming':
         for a in self.re_PostBoth2.finditer(hand.handText):
             bet = self.clearMoneyString(a.group('SBBB'))
             amount = str(Decimal(bet) + Decimal(bet)/2)
             hand.addBlind(a.group('PNAME'), 'both', amount)
     else:
         for a in self.re_PostBoth1.finditer(hand.handText):
             self.adjustMergeTourneyStack(hand, a.group('PNAME'), a.group('SBBB'))
             hand.addBlind(a.group('PNAME'), 'both', self.clearMoneyString(a.group('SBBB')))
         
     # FIXME
     # The following should only trigger when a small blind is missing in a tournament, or the sb/bb is ALL_IN
     # see http://sourceforge.net/apps/mantisbt/fpdb/view.php?id=115
     if hand.gametype['type'] == 'tour' and self.sitename in ('Merge', 'iPoker'):
         if hand.gametype['sb'] == None and hand.gametype['bb'] == None:
             hand.gametype['sb'] = "1"
             hand.gametype['bb'] = "2"
         elif hand.gametype['sb'] == None:
             hand.gametype['sb'] = str(int(Decimal(hand.gametype['bb']))/2)
         elif hand.gametype['bb'] == None:
             hand.gametype['bb'] = str(int(Decimal(hand.gametype['sb']))*2)
         if int(Decimal(hand.gametype['bb']))/2 != int(Decimal(hand.gametype['sb'])):
             if int(Decimal(hand.gametype['bb']))/2 < int(Decimal(hand.gametype['sb'])):
                 hand.gametype['bb'] = str(int(Decimal(hand.gametype['sb']))*2)
             else:
                 hand.gametype['sb'] = str(int(Decimal(hand.gametype['bb']))/2)
예제 #3
0
    def parseSummary(self):
        m = self.re_TourneyInfo.search(self.summaryText)
        if m == None:
            tmp = self.summaryText[0:200]
            log.error(_("PokerTrackerSummary.parseSummary: '%s'") % tmp)
            raise FpdbParseError

        #print "DEBUG: m.groupdict(): %s" % m.groupdict()

        mg = m.groupdict()
        if 'SITE'    in mg:
            self.siteName = mg['SITE'].replace('MicroGaming', 'Microgaming')
            self.siteId   = self.SITEIDS.get(self.siteName)
            if self.siteId is None:
                tmp = self.summaryText[0:200]
                log.error(_("PokerTrackerSummary.parseSummary: Unsupported site summary '%s'") % tmp)
                raise FpdbParseError
        if 'TOURNO'    in mg: self.tourNo = mg['TOURNO']
        if 'LIMIT'     in mg and mg['LIMIT'] is not None:
            self.gametype['limitType'] = self.limits[mg['LIMIT']]
        else:
            self.gametype['limitType'] = 'fl'
        if 'TYPE'      in mg: self.tourneyName = mg['TYPE']
        if 'GAME'      in mg: self.gametype['category']  = self.games[mg['GAME']][1]
        if mg['BUYIN'] != None:
            self.buyin = int(100*Decimal(self.clearMoneyString(mg['BUYIN'])))
        if mg['FEE'] != None:
            self.fee   = int(100*Decimal(self.clearMoneyString(mg['FEE'])))
        if 'REBUYAMT'in mg and mg['REBUYAMT'] != None:
            self.isRebuy   = True
            self.rebuyCost = int(100*Decimal(self.clearMoneyString(mg['REBUYAMT'])))
        if 'ADDON' in mg and mg['ADDON'] != None:
            self.isAddOn = True
            self.addOnCost = int(100*Decimal(self.clearMoneyString(mg['ADDON'])))
        if 'ENTRIES'   in mg:
            self.entries = mg['ENTRIES']
            self.prizepool = int(Decimal(self.clearMoneyString(mg['BUYIN']))) * int(self.entries)
        if 'DATETIME'  in mg: 
            if self.siteName in ('iPoker', 'Microgaming'):
                m1 = self.re_DateTime1.finditer(mg['DATETIME'])
            elif self.siteName == 'Merge':
                m1 = self.re_DateTime2.finditer(mg['DATETIME'])
            elif self.siteName == 'Everest':
                m1 = self.re_DateTime3.finditer(mg['DATETIME'])
        datetimestr = "2000/01/01 00:00:00"  # default used if time not found
        for a in m1:
            datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'), a.group('M'),a.group('D'),a.group('H'),a.group('MIN'),a.group('S'))
            
        self.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"

        if mg['CURRENCY'] == "$":     self.buyinCurrency="USD"
        elif mg['CURRENCY'] == u"€":  self.buyinCurrency="EUR"
        elif not mg['CURRENCY']:      self.buyinCurrency="play"
        if self.buyin == 0:           self.buyinCurrency="FREE"
        self.currency = self.buyinCurrency

        m = self.re_Player.finditer(self.summaryText)
        for a in m:
            mg = a.groupdict()
            #print "DEBUG: a.groupdict(): %s" % mg
            name = mg['NAME']
            rank = int(mg['RANK'])
            winnings = 0
            rebuyCount = 0
            addOnCount = 0
            koCount = 0

            if 'WINNINGS' in mg and mg['WINNINGS'] != None:
                winnings = int(100*Decimal(mg['WINNINGS']))
                
            if 'REBUYS' in mg and mg['REBUYS']!=None:
                rebuyCount = int(mg['REBUYS'])
                
            if 'ADDONS' in mg and mg['ADDONS']!=None:
                addOnCount = int(mg['ADDONS'])
                
            if 'CUR' in mg and mg['CUR'] != None:
                if mg['CUR'] == "$":     self.currency="USD"
                elif mg['CUR'] == u"€":  self.currency="EUR"
                elif mg['CUR'] == "FPP": self.currency="PSFP"

            if rank==0:
                #print "stillplaying"
                rank=None
                winnings=None

            #TODO: currency, ko/addon/rebuy count -> need examples!
            #print "DEBUG: addPlayer(%s, %s, %s, %s, None, None, None)" %(rank, name, winnings, self.currency)
            #print "DEBUG: self.buyin: %s self.fee %s" %(self.buyin, self.fee)
            self.addPlayer(rank, name, winnings, self.currency, rebuyCount, addOnCount, koCount)
예제 #4
0
 def readPlayerStacks(self, hand):
     m = self.re_PlayerInfo.finditer(hand.handText)
     for a in m:
         stack = Decimal(a.group('CASH'))
         stackstr = "%.2f" % float(stack/100)
         hand.addPlayer(a.group('SEAT'), a.group('PNAME'), stackstr)
예제 #5
0
    def readHandInfo(self, hand):
        info = {}
        if self.skin in ('ActionPoker', 'GearPoker'):
            m = self.re_HandInfo2.search(hand.handText, re.DOTALL)
        else:
            m = self.re_HandInfo1.search(hand.handText, re.DOTALL)
        m2 = self.re_GameInfo.search(hand.handText)
        if m is None or m2 is None:
            tmp = hand.handText[0:200]
            log.error(_("BetOnlineToFpdb.readHandInfo: '%s'") % tmp)
            raise FpdbParseError

        info.update(m.groupdict())
        info.update(m2.groupdict())

        #print 'DEBUG:', info
        for key in info:
            if key == 'DATETIME':
                #2008/11/12 10:00:48 CET [2008/11/12 4:00:48 ET] # (both dates are parsed so ET date overrides the other)
                #2008/08/17 - 01:14:43 (ET)
                #2008/09/07 06:23:14 ET

                datetimestr, time_zone = "2000/01/01 00:00:00", 'ET'  # default used if time not found
                if self.skin not in ('ActionPoker', 'GearPoker'):
                    m1 = self.re_DateTime1.finditer(info[key])
                    for a in m1:
                        seconds = '00'
                        if a.group('S'):
                            seconds = a.group('S')
                        datetimestr = "%s/%s/%s %s:%s:%s" % (
                            a.group('Y'), a.group('M'), a.group('D'),
                            a.group('H'), a.group('MIN'), seconds)
                        tz = a.group('TZ')  # just assume ET??
                        if tz == 'GMT Standard Time':
                            time_zone = 'GMT'
                        elif tz in ('Pacific Daylight Time',
                                    'Pacific Standard Time'):
                            time_zone = 'PT'
                        else:
                            time_zone = 'ET'
                else:
                    m2 = self.re_DateTime2.finditer(info[key])
                    for a in m2:
                        datetimestr = "%s/%s/%s %s:%s:%s" % (
                            a.group('Y'), a.group('M'), a.group('D'),
                            a.group('H'), a.group('MIN'), a.group('S'))
                        time_zone = 'ET'
                    #print "   tz = ", tz, " datetime =", datetimestr
                hand.startTime = datetime.datetime.strptime(
                    datetimestr,
                    "%Y/%m/%d %H:%M:%S")  # also timezone at end, e.g. " ET"
                hand.startTime = HandHistoryConverter.changeTimezone(
                    hand.startTime, time_zone, "UTC")
            if key == 'HID':
                hand.handid = info[key]
            if key == 'MONEY':
                if info[key] == '(Play Money) ':
                    hand.gametype['currency'] = 'play'
            if key == 'TOURNO':
                hand.tourNo = info[key]
            if key == 'BUYIN':
                if hand.tourNo != None:
                    #print "DEBUG: info['BUYIN']: %s" % info['BUYIN']
                    #print "DEBUG: info['BIAMT']: %s" % info['BIAMT']
                    #print "DEBUG: info['BIRAKE']: %s" % info['BIRAKE']
                    #print "DEBUG: info['BOUNTY']: %s" % info['BOUNTY']
                    if not info[key] or info[key] == 'Freeroll':
                        hand.buyin = 0
                        hand.fee = 0
                        hand.buyinCurrency = "FREE"
                    else:
                        if info[key].find("$") != -1:
                            hand.buyinCurrency = "USD"
                        elif info[key].find(u"€") != -1:
                            hand.buyinCurrency = "EUR"
                        elif re.match("^[0-9+]*$", info[key]):
                            hand.buyinCurrency = "play"
                        else:
                            #FIXME: handle other currencies, play money
                            raise FpdbParseError(
                                _("BetOnlineToFpdb.readHandInfo: Failed to detect currency."
                                  ) + " " + _("Hand ID") + ": %s: '%s'" %
                                (hand.handid, info[key]))

                        info['BIAMT'] = info['BIAMT'].strip(u'$€')
                        if info['BOUNTY'] != None:
                            # There is a bounty, Which means we need to switch BOUNTY and BIRAKE values
                            tmp = info['BOUNTY']
                            info['BOUNTY'] = info['BIRAKE']
                            info['BIRAKE'] = tmp
                            info['BOUNTY'] = info['BOUNTY'].strip(
                                u'$€')  # Strip here where it isn't 'None'
                            hand.koBounty = int(100 * Decimal(info['BOUNTY']))
                            hand.isKO = True
                        else:
                            hand.isKO = False

                        info['BIRAKE'] = info['BIRAKE'].strip(u'$€')

                        hand.buyin = int(100 * Decimal(info['BIAMT']))
                        hand.fee = int(100 * Decimal(info['BIRAKE']))
            if key == 'LEVEL':
                hand.level = info[key]

            if key == 'TABLE':
                if hand.tourNo != None:
                    hand.tablename = re.split("-", info[key])[1]
                else:
                    hand.tablename = info[key]
            if key == 'BUTTON':
                hand.buttonpos = info[key]
            if key == 'MAX' and info[key] != None:
                hand.maxseats = int(info[key])
        if not self.re_Board1.search(hand.handText) and self.skin not in (
                'ActionPoker', 'GearPoker'):
            raise FpdbHandPartial("readHandInfo: " +
                                  _("Partial hand history") +
                                  ": '%s'" % hand.handid)
예제 #6
0
    def readHandInfo(self, hand):
        info = {}
        m = self.re_HandInfo.search(hand.handText, re.DOTALL)
        if m is None:
            log.error("re_HandInfo could not be parsed")
        m2 = self.re_GameInfo.search(hand.handText)
        if m2 is None:
            log.error("re_GameInfo could not be parsed")
        if m is None or m2 is None:
            tmp = hand.handText[0:200]
            log.error(_("PacificPokerToFpdb.readHandInfo: '%s'") % tmp)
            raise FpdbParseError

        info.update(m.groupdict())
        info.update(m2.groupdict())

        #log.debug("readHandInfo: %s" % info)
        for key in info:
            if key == 'DATETIME':
                # 28 11 2011 19:05:11
                m1 = self.re_DateTime.finditer(info[key])
                datetimestr = "2000/01/01 00:00:00"  # default used if time not found
                for a in m1:
                    datetimestr = "%s/%s/%s %s:%s:%s" % (
                        a.group('Y'), a.group('M'), a.group('D'), a.group('H'),
                        a.group('MIN'), a.group('S'))
                hand.startTime = datetime.datetime.strptime(
                    datetimestr, "%Y/%m/%d %H:%M:%S")
                hand.startTime = HandHistoryConverter.changeTimezone(
                    hand.startTime, "ET", "UTC")
            if key == 'HID':
                hand.handid = info[key]
            if key == 'TOURNO' and info['TOURNO'] != None:
                hand.tourNo = info[key]
                hand.isKO = False
            if key == 'BUYIN' and info['BUYIN'] != None:
                if info[key] == 'Free' or info['BIAMT'] is None:
                    hand.buyin = 0
                    hand.fee = 0
                    hand.buyinCurrency = "FREE"
                else:
                    if info['BUYIN'].find("$") != -1:
                        hand.buyinCurrency = "USD"
                    elif info['BUYIN'].find(u"€") != -1:
                        hand.buyinCurrency = "EUR"
                    elif 'PLAY' in info and info['PLAY'] != "Practice Play":
                        hand.buyinCurrency = "FREE"
                    else:
                        #FIXME: handle other currencies, FPP, play money
                        log.error(
                            _("PacificPokerToFpdb.readHandInfo: Failed to detect currency."
                              ) + " Hand ID: %s: '%s'" %
                            (hand.handid, info[key]))
                        raise FpdbParseError

                    info['BIAMT'] = self.clearMoneyString(
                        info['BIAMT'].strip(u'$€'))
                    hand.buyin = int(100 * Decimal(info['BIAMT']))

                    if info['BIRAKE'] is None:
                        hand.fee = 0
                    else:
                        info['BIRAKE'] = self.clearMoneyString(
                            info['BIRAKE'].strip(u'$€'))
                        hand.fee = int(100 * Decimal(info['BIRAKE']))

            if key == 'TABLE' and info['TABLE'] != None:
                hand.tablename = info[key]
            if key == 'TABLEID' and info['TABLEID'] != None:
                hand.tablename = info[key]
            if key == 'BUTTON':
                hand.buttonpos = info[key]
            if key == 'MAX' and info['MAX'] != None:
                hand.maxseats = int(info[key])

            if key == 'PLAY' and info['PLAY'] is not None:
                #hand.currency = 'play' # overrides previously set value
                hand.gametype['currency'] = 'play'
예제 #7
0
    def readHandInfo(self, hand):
        info = {}
        m = self.re_HandInfo.search(hand.handText)
        if m is None:
            tmp = hand.handText[0:200]
            log.error(_("WinamaxToFpdb.readHandInfo: '%s'") % tmp)
            raise FpdbParseError

        info.update(m.groupdict())
        #log.debug("readHandInfo: %s" % info)
        for key in info:
            if key == 'DATETIME':
                a = self.re_DateTime.search(info[key])
                if a:
                    datetimestr = "%s/%s/%s %s:%s:%s" % (
                        a.group('Y'), a.group('M'), a.group('D'), a.group('H'),
                        a.group('MIN'), a.group('S'))
                else:
                    datetimestr = "2010/Jan/01 01:01:01"
                    log.error("readHandInfo: " +
                              _("DATETIME not matched: '%s'") % info[key])
                    #print "DEBUG: readHandInfo: DATETIME not matched: '%s'" % info[key]
                hand.startTime = datetime.datetime.strptime(
                    datetimestr, "%Y/%m/%d %H:%M:%S")
            if key == 'HID1':
                # Need to remove non-alphanumerics for MySQL
                # Concatenating all three or just HID2 + HID3 can produce out of range values
                # HID should not be greater than 14 characters to ensure this
                hand.handid = "%s%s" % (int(
                    info['HID1'][:14]), int(info['HID2']))

#            if key == 'HID3':
#                hand.handid = int(info['HID3'])   # correct hand no (REB)
            if key == 'TOURNO':
                hand.tourNo = info[key]
            if key == 'TABLE':
                hand.tablename = info[key]
                if hand.gametype['type'] == 'tour':
                    hand.tablename = info['TABLENO']
                    hand.roundPenny = True
                # TODO: long-term solution for table naming on Winamax.
                if hand.tablename.endswith(u'No Limit Hold\'em'):
                    hand.tablename = hand.tablename[:-len(u'No Limit Hold\'em'
                                                          )] + u'NLHE'
            if key == 'MAXPLAYER' and info[key] != None:
                hand.maxseats = int(info[key])

            if key == 'BUYIN':
                if hand.tourNo != None:
                    #print "DEBUG: info['BUYIN']: %s" % info['BUYIN']
                    #print "DEBUG: info['BIAMT']: %s" % info['BIAMT']
                    #print "DEBUG: info['BIRAKE']: %s" % info['BIRAKE']
                    #print "DEBUG: info['BOUNTY']: %s" % info['BOUNTY']
                    for k in ['BIAMT', 'BIRAKE']:
                        if k in info.keys() and info[k]:
                            info[k] = info[k].replace(',', '.')

                    if info['FREETICKET'] is not None:
                        hand.buyin = 0
                        hand.fee = 0
                        hand.buyinCurrency = "FREE"
                    else:
                        if info[key].find("$") != -1:
                            hand.buyinCurrency = "USD"
                        elif info[key].find(u"€") != -1:
                            hand.buyinCurrency = "EUR"
                        elif info[key].find("FPP") != -1:
                            hand.buyinCurrency = "WIFP"
                        elif info[key].find("Free") != -1:
                            hand.buyinCurrency = "WIFP"
                        elif info['MONEY']:
                            hand.buyinCurrency = "EUR"
                        else:
                            hand.buyinCurrency = "play"

                        if info['BIAMT'] is not None:
                            info['BIAMT'] = info['BIAMT'].strip(u'$€FPP')
                        else:
                            info['BIAMT'] = 0

                        if hand.buyinCurrency != "WIFP":
                            if info['BOUNTY'] != None:
                                # There is a bounty, Which means we need to switch BOUNTY and BIRAKE values
                                tmp = info['BOUNTY']
                                info['BOUNTY'] = info['BIRAKE']
                                info['BIRAKE'] = tmp
                                info['BOUNTY'] = info['BOUNTY'].strip(
                                    u'$€')  # Strip here where it isn't 'None'
                                hand.koBounty = int(100 *
                                                    Decimal(info['BOUNTY']))
                                hand.isKO = True
                            else:
                                hand.isKO = False

                            info['BIRAKE'] = info['BIRAKE'].strip(u'$€')

                            # TODO: Is this correct? Old code tried to
                            # conditionally multiply by 100, but we
                            # want hand.buyin in 100ths of
                            # dollars/euros (so hand.buyin = 90 for $0.90 BI).
                            hand.buyin = int(100 * Decimal(info['BIAMT']))
                            hand.fee = int(100 * Decimal(info['BIRAKE']))
                        else:
                            hand.buyin = int(Decimal(info['BIAMT']))
                            hand.fee = 0
                        if hand.buyin == 0 and hand.fee == 0:
                            hand.buyinCurrency = "FREE"

            if key == 'LEVEL':
                hand.level = info[key]

        hand.mixed = None
예제 #8
0
    def determineGameType(self, handText):
        info = {}
        m = self.re_GameInfo.search(handText)
        if not m:
            # BetOnline starts writing the hh the moment you sit down.
            # Test if the hh contains the join line, and throw a partial if so.
            m2 = self.re_JoinsTable.search(handText)
            if not m2:
                tmp = handText[0:200]
                log.error(_("BetOnlineToFpdb.determineGameType: '%s'") % tmp)
                raise FpdbParseError
            else:
                raise FpdbHandPartial(
                    "BetOnlineToFpdb.determineGameType: " +
                    _("Partial hand history: 'Player joining table'"))

        mg = m.groupdict()
        if mg['LIMIT']:
            info['limitType'] = self.limits[mg['LIMIT']]
            if info['limitType'] == 'pl':
                m = self.re_HeroCards.search(handText)
                if m and len(m.group('NEWCARDS').split(' ')) == 4:
                    (info['base'], info['category']) = self.games['Omaha']
        else:
            info['limitType'] = self.limits['No Limit']
        if 'SKIN' in mg:
            self.skin = self.skins[mg['SKIN']]
        if 'GAME' in mg and not info.get('base'):
            (info['base'], info['category']) = self.games[mg['GAME']]
        if 'SB' in mg:
            info['sb'] = self.clearMoneyString(mg['SB'])
        if 'BB' in mg:
            info['bb'] = self.clearMoneyString(mg['BB'])
        if 'CURRENCY' in mg and mg['CURRENCY'] is not None:
            info['currency'] = self.currencies[mg['CURRENCY']]
        else:
            info['currency'] = 'USD'
        if 'MIXED' in mg:
            if mg['MIXED'] is not None: info['mix'] = self.mixes[mg['MIXED']]

        if 'TOURNO' in mg and mg['TOURNO'] is None:
            info['type'] = 'ring'
        else:
            info['type'] = 'tour'

        if info['limitType'] == 'fl' and info['bb'] is not None:
            if info['type'] == 'ring':
                try:
                    info['sb'] = self.Lim_Blinds[info['BB']][0]
                    info['bb'] = self.Lim_Blinds[info['BB']][1]
                except KeyError:
                    tmp = handText[0:200]
                    log.error(
                        _("BetOnlineToFpdb.determineGameType: Lim_Blinds has no lookup for '%s' - '%s'"
                          ) % (mg['BB'], tmp))
                    raise FpdbParseError
            else:
                info['sb'] = str(
                    (Decimal(info['SB']) / 2).quantize(Decimal("0.01")))
                info['bb'] = str(Decimal(info['SB']).quantize(Decimal("0.01")))

        return info
예제 #9
0
    def readHandInfo(self, hand):
        info = {}
        m = self.re_GameInfo.search(hand.handText)
        if m is None:
            tmp = hand.handText[0:200]
            log.error(_("BovadaToFpdb.readHandInfo: '%s'") % tmp)
            raise FpdbParseError
        
        info.update(m.groupdict())
        m = self.re_Buyin.search(self.in_path)
        if m: info.update(m.groupdict())
        hand.allInBlind = False
        
        for key in info:
            if key == 'DATETIME':
                m1 = self.re_DateTime.finditer(info[key])
                datetimestr = "2000/01/01 00:00:00"  # default used if time not found
                for a in m1:
                    datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'), a.group('M'),a.group('D'),a.group('H'),a.group('MIN'),a.group('S'))
                    #tz = a.group('TZ')  # just assume ET??
                    #print "   tz = ", tz, " datetime =", datetimestr
                hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"
                hand.startTime = HandHistoryConverter.changeTimezone(hand.startTime, "ET", "UTC")
            if key == 'HID':
                hand.handid = info[key]
            if key == 'TOURNO':
                hand.tourNo = info[key]
            if key == 'BUYIN':
                if info['TOURNO']!=None:
                    if info[key] == 'Freeroll':
                        hand.buyin = 0
                        hand.fee = 0
                        hand.buyinCurrency = "FREE"
                    else:
                        if info[key].find("$")!=-1:
                            hand.buyinCurrency="USD"
                        elif re.match("^[0-9+]*$", info[key]):
                            hand.buyinCurrency="play"
                        else:
                            #FIXME: handle other currencies, play money
                            log.error(_("BovadaToFpdb.readHandInfo: Failed to detect currency.") + " Hand ID: %s: '%s'" % (hand.handid, info[key]))
                            raise FpdbParseError

                        info['BIAMT'] = info['BIAMT'].strip(u'$')
                        
                        if info['BIRAKE']:
                            info['BIRAKE'] = info['BIRAKE'].strip(u'$')
                        else:
                            info['BIRAKE'] = '0'

                        hand.buyin = int(100*Decimal(info['BIAMT']))
                        hand.fee = int(100*Decimal(info['BIRAKE']))

            if key == 'TABLE':
                if info.get('TABLENO'):
                    hand.tablename = info.get('TABLENO')
                elif info['ZONE'] and 'Zone' in info['ZONE']:
                    hand.tablename = info['ZONE'] + ' ' +info[key]
                else:
                    hand.tablename = info[key]        
            if key == 'MAX' and info[key] != None:
                hand.maxseats = int(info[key])
            if key == 'HU' and info[key] != None:
                hand.maxseats = 2
                
        if not hand.maxseats:
            hand.maxseats = 9          
예제 #10
0
    def parseSummary(self):
        obj = getattr(BovadaToFpdb, "Bovada", None)
        hhc = obj(self.config, in_path = self.in_path, sitename = None, autostart = False)
        m = hhc.re_GameInfo.search(self.summaryText)
        if m == None:
            tmp = self.summaryText[0:200]
            log.error(_("BovadaSummary.parseSummary: '%s'") % tmp)
            raise FpdbParseError
        
        info = {}
        info.update(m.groupdict())
        m = hhc.re_Buyin.search(self.in_path)
        if m: info.update(m.groupdict())
        
        if info['TOURNO'] is None:
            tmp = self.summaryText[0:200]
            log.error(_("BovadaSummary.parseSummary: Text does not appear to be a tournament '%s'") % tmp)
            raise FpdbParseError
        else:
            self.tourNo = info['TOURNO']
            if 'LIMIT' in info:
                if not info['LIMIT']:
                    self.gametype['limitType'] = 'nl'
                else:
                    self.gametype['limitType'] = hhc.limits[info['LIMIT']]
            if 'GAME' in info:
                self.gametype['category'] = hhc.games[info['GAME']][1]
                 
            if 'CURRENCY' in info and info['CURRENCY']:
                self.buyinCurrency = hhc.currencies[info['CURRENCY']]
            self.currency = self.buyinCurrency
            
            if 'DATETIME' in info and info['CURRENCY'] is not None:
                m1 = hhc.re_DateTime.finditer(info['DATETIME'])
                datetimestr = "2000/01/01 00:00:00"  # default used if time not found
                for a in m1:
                    datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'), a.group('M'),a.group('D'),a.group('H'),a.group('MIN'),a.group('S'))
                    #tz = a.group('TZ')  # just assume ET??
                    #print "   tz = ", tz, " datetime =", datetimestr
                self.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"
                self.startTime = HandHistoryConverter.changeTimezone(self.startTime, "ET", "UTC")
                
            self.buyin = 0
            self.fee   = 0
            self.prizepool = None
            self.entries   = None
            
            if self.currency is None:
                self.buyinCurrency = "FREE"
            
            if 'BUYIN' in info and info['BUYIN'] is not None:
                if info['BIAMT'] is not None and info['BIRAKE'] is not None:
                    if info['BUYIN'].find("$")!=-1:
                        self.buyinCurrency="USD"
                    elif re.match("^[0-9+]*$", info['BUYIN']):
                        self.buyinCurrency="play"
                    else:
                        log.error(_("BovadaSummary.parseSummary: Failed to detect currency"))
                        raise FpdbParseError
                    self.currency = self.buyinCurrency

                    info['BIAMT'] = info['BIAMT'].strip(u'$')
                    
                    if info['BIRAKE']:
                        info['BIRAKE'] = info['BIRAKE'].strip(u'$')
                    else:
                        info['BIRAKE'] = '0'

                    self.buyin = int(100*Decimal(info['BIAMT']))
                    self.fee = int(100*Decimal(info['BIRAKE']))
                    
                    if info['TOURNAME'] is not None:
                        tourneyNameFull = info['TOURNAME'] + ' - ' + info['BIAMT'] + '+' + info['BIRAKE']
                        self.tourneyName = tourneyNameFull
                        
                        if 'TOURNAME' in info and 'Rebuy' in info['TOURNAME']:
                            self.isAddOn, self.isRebuy = True, True
                            self.rebuyCost = self.buyin
                            self.addOnCost = self.buyin
            
            rank, winnings, rebuys, addons = None, None, None, None
            
            m = self.re_Ranking.search(self.summaryText)
            if m and m.group('RANK') is not None: 
                rank = int(m.group('RANK'))
                winnings = 0
                
            m = self.re_Winnings.search(self.summaryText)
            if m and m.group('WINNINGS') is not None: 
                if m.group('WINNINGS').find("$")!=-1:
                    self.currency="USD"
                elif re.match("^[0-9+]*$", m.group('WINNINGS')):
                    self.currency="play"
                winnings = int(100*Decimal(self.clearMoneyString(m.group('WINNINGS'))))
                
            m = self.re_Rebuyin.finditer(self.summaryText)
            for a in m: 
                if rebuys == None: 
                    rebuys = 0
                rebuys += 1
                
            m = self.re_AddOn.finditer(self.summaryText)
            for a in m: 
                if addons == None:
                    addons = 0
                addons += 1
                            
            self.addPlayer(rank, 'Hero', winnings, self.currency, rebuys, addons, None)
예제 #11
0
    def readHandInfo(self, hand):
        info = {}
        m  = self.re_HandInfo.search(hand.handText,re.DOTALL)
        m2 = self.re_GameInfo.search(hand.handText)
        if m is None or m2 is None:
            tmp = hand.handText[0:200]
            log.error(_("EnetToFpdb.readHandInfo: '%s'") % tmp)
            raise FpdbParseError

        info.update(m.groupdict())
        info.update(m2.groupdict())

        #log.debug("readHandInfo: %s" % info)
        for key in info:
            if key == 'LIMIT':
                hand.gametype['limitType'] = self.limits[info[key]]
            if key == 'DATETIME':
                #2008/11/12 10:00:48 CET [2008/11/12 4:00:48 ET] # (both dates are parsed so ET date overrides the other)
                #2008/08/17 - 01:14:43 (ET)
                #2008/09/07 06:23:14 ET
                m1 = self.re_DateTime.finditer(info[key])
                datetimestr = "2000/01/01 00:00:00"  # default used if time not found
                for a in m1:
                    datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'), a.group('M'),a.group('D'),a.group('H'),a.group('MIN'),a.group('S'))
                    #tz = a.group('TZ')  # just assume ET??
                    #print "   tz = ", tz, " datetime =", datetimestr
                hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"
                #hand.startTime = HandHistoryConverter.changeTimezone(hand.startTime, "ET", "UTC")
            if key == 'HID':
                hand.handid = info[key]
            if key == 'TOURNO':
                hand.tourNo = info[key]
            if key == 'BUYIN':
                if hand.tourNo!=None:
                    #print "DEBUG: info['BUYIN']: %s" % info['BUYIN']
                    #print "DEBUG: info['BIAMT']: %s" % info['BIAMT']
                    #print "DEBUG: info['BIRAKE']: %s" % info['BIRAKE']
                    #print "DEBUG: info['BOUNTY']: %s" % info['BOUNTY']
                    if info[key] == 'Freeroll':
                        hand.buyin = 0
                        hand.fee = 0
                        hand.buyinCurrency = "FREE"
                    else:
                        if info[key].find("$")!=-1:
                            hand.buyinCurrency="USD"
                        elif info[key].find(u"£")!=-1:
                            hand.buyinCurrency="GBP"
                        elif info[key].find(u"€")!=-1:
                            hand.buyinCurrency="EUR"
                        elif re.match("^[0-9+]*$", info[key]):
                            hand.buyinCurrency="play"
                        else:
                            #FIXME: handle other currencies, play money
                            log.error(_("EnetToFpdb.readHandInfo: Failed to detect currency.") + " Hand ID: %s: '%s'" % (hand.handid, info[key]))
                            raise FpdbParseError

                        info['BIAMT'] = info['BIAMT'].strip(u'$€£')
                        info['BIRAKE'] = info['BIRAKE'].strip(u'$€£')
                        hand.buyin = int(100*Decimal(self.clearMoneyString(info['BIAMT'])))
                        hand.fee = int(100*Decimal(self.clearMoneyString(info['BIRAKE'])))
            if key == 'LEVEL':
                hand.level = info[key]
            if key == 'TABLE':
                if hand.tourNo != None:
                    hand.tablename = re.split(" ", info[key])[1]
                else:
                    hand.tablename = info[key]
            if key == 'BUTTON':
                hand.buttonpos = info[key]
            if key == 'MAX' and info[key] != None:
                hand.maxseats = int(info[key])
예제 #12
0
    def determineGameType(self, handText):

        m = self.re_GameInfo.search(handText)
        if not m: return None

        self.info = {}
        mg = m.groupdict()
        tourney = False
        #print "DEBUG: m.groupdict(): %s" % mg
        if mg['GAME'][:2] == 'LH':
            mg['CATEGORY'] = 'Holdem'
            mg['LIMIT'] = 'L'
            mg['BB'] = mg['LBB']
        if 'GAME' in mg:
            (self.info['base'],
             self.info['category']) = self.games[mg['CATEGORY']]
        if 'LIMIT' in mg:
            self.info['limitType'] = self.limits[mg['LIMIT']]
        if 'HERO' in mg:
            self.hero = mg['HERO']
        if 'SB' in mg:
            self.info['sb'] = self.clearMoneyString(mg['SB'])
            if not mg['SB']: tourney = True
        if 'BB' in mg:
            self.info['bb'] = self.clearMoneyString(mg['BB'])

        if tourney:
            self.info['type'] = 'tour'
            self.info['currency'] = 'T$'
            # FIXME: The sb/bb isn't listed in the game header. Fixing to 1/2 for now
            self.tinfo = {
            }  # FIXME?: Full tourney info is only at the top of the file. After the
            #         first hand in a file, there is no way for auto-import to
            #         gather the info unless it reads the entire file every time.
            self.tinfo['tourNo'] = mg['TABLE'].split(',')[-1].strip().split(
                ' ')[0]
            self.tablename = '1'
            if not mg['CURRENCY'] or mg['CURRENCY'] == 'fun':
                self.tinfo['buyinCurrency'] = 'play'
            else:
                self.tinfo['buyinCurrency'] = mg['CURRENCY']
            self.tinfo['buyin'] = 0
            self.tinfo['fee'] = 0
            m2 = self.re_GameInfoTrny.search(handText)
            if m2:
                mg = m2.groupdict()
                if not mg['BIRAKE'] and mg['TOTBUYIN']:
                    m3 = self.re_TotalBuyin.search(mg['TOTBUYIN'])
                    if m3:
                        mg = m3.groupdict()
                    elif mg['BIAMT']:
                        mg['BIRAKE'] = '0'
                if self.re_FPP.match(mg['BIAMT']):
                    self.tinfo['buyinCurrency'] = 'FPP'
                if mg['BIRAKE']:
                    #FIXME: tournament no looks liek it is in the table name
                    mg['BIRAKE'] = self.clearMoneyString(
                        self.re_non_decimal.sub('', mg['BIRAKE']))
                    mg['BIAMT'] = self.clearMoneyString(
                        self.re_non_decimal.sub('', mg['BIAMT']))
                    m4 = self.re_Buyin.search(mg['BIAMT'])
                    if m4:
                        mg['BIAMT'] = m4.group('BUYIN')
                        self.tinfo['fee'] = int(100 * Decimal(
                            self.clearMoneyString(
                                self.re_non_decimal.sub('', mg['BIRAKE']))))
                        self.tinfo['buyin'] = int(100 * Decimal(
                            self.clearMoneyString(
                                self.re_non_decimal.sub('', mg['BIAMT']))))
                        if 'BIRAKE1' in mg and mg['BIRAKE1']:
                            self.tinfo['buyin'] += int(100 * Decimal(
                                self.clearMoneyString(
                                    self.re_non_decimal.sub('',
                                                            mg['BIRAKE1']))))
                    # FIXME: <place> and <win> not parsed at the moment.
                    #  NOTE: Both place and win can have the value N/A
            if self.tinfo['buyin'] == 0:
                self.tinfo['buyinCurrency'] = 'FREE'
        else:
            self.info['type'] = 'ring'
            self.tablename = mg['TABLE']
            if not mg['TABLECURRENCY'] and not mg['CURRENCY']:
                self.info['currency'] = 'play'
            elif not mg['TABLECURRENCY']:
                self.info['currency'] = mg['CURRENCY']
            else:
                self.info['currency'] = mg['TABLECURRENCY']

            if self.info['limitType'] == 'fl' and self.info['bb'] is not None:
                try:
                    self.info['sb'] = self.Lim_Blinds[self.clearMoneyString(
                        mg['BB'])][0]
                    self.info['bb'] = self.Lim_Blinds[self.clearMoneyString(
                        mg['BB'])][1]
                except KeyError:
                    tmp = handText[0:200]
                    log.error(
                        _("iPokerToFpdb.determineGameType: Lim_Blinds has no lookup for '%s' - '%s'"
                          ) % (mg['BB'], tmp))
                    raise FpdbParseError

        return self.info
예제 #13
0
    def parseSummary(self):
        m = self.re_TourneyInfo.search(self.summaryText)
        if m == None:
            tmp = self.summaryText[0:200]
            log.error(_("PokerTrackerSummary.parseSummary: '%s'") % tmp)
            raise FpdbParseError

        #print "DEBUG: m.groupdict(): %s" % m.groupdict()

        mg = m.groupdict()
        if 'SITE' in mg:
            if self.siteNameMap.get(mg['SITE']) != None:
                self.siteName = self.siteNameMap.get(mg['SITE'])
                self.siteId = self.SITEIDS.get(self.siteName)
            else:
                tmp = self.summaryText[0:200]
                log.error(
                    _("PokerTrackerSummary.parseSummary: Unsupported site summary '%s'"
                      ) % tmp)
                raise FpdbParseError
        if 'TOURNO' in mg: self.tourNo = mg['TOURNO']
        if 'GAME' in mg: self.gametype['category'] = self.games[mg['GAME']][1]
        if mg['LIMIT'] in self.limits:
            self.gametype['limitType'] = self.limits[mg['LIMIT']]
        elif self.gametype['category'] == 'holdem':
            self.gametype['limitType'] = 'nl'
        else:
            self.gametype['limitType'] = 'pl'
        if 'TYPE' in mg: self.tourneyName = mg['TYPE']
        if mg['BUYIN'] != None:
            self.buyin = int(100 * Decimal(self.clearMoneyString(mg['BUYIN'])))
        if mg['FEE'] != None:
            self.fee = int(100 * Decimal(self.clearMoneyString(mg['FEE'])))
        if 'REBUYAMT' in mg and mg['REBUYAMT'] != None:
            self.isRebuy = True
            self.rebuyCost = int(
                100 * Decimal(self.clearMoneyString(mg['REBUYAMT'])))
        if 'PRIZEPOOL' in mg and mg['PRIZEPOOL'] != None:
            self.prizepool = int(
                100 * Decimal(self.clearMoneyString(mg['PRIZEPOOL'])))
        if 'ADDON' in mg and mg['ADDON'] != None:
            self.isAddOn = True
            self.addOnCost = int(100 *
                                 Decimal(self.clearMoneyString(mg['ADDON'])))
        if 'BOUNTY' in mg and mg['BOUNTY'] != None:
            self.koBounty = int(100 *
                                Decimal(self.clearMoneyString(mg['BOUNTY'])))
            self.isKO = True
        if 'ENTRIES' in mg:
            self.entries = mg['ENTRIES']
        if 'DATETIME' in mg:
            m1 = self.re_DateTime.finditer(mg['DATETIME'])
            for a in m1:
                datetimestr = "%s/%s/%s %s:%s:%s" % (
                    a.group('Y'), a.group('M'), a.group('D'), a.group('H'),
                    a.group('MIN'), a.group('S'))
        else:
            datetimestr = "2000/01/01 00:00:00"  # default used if time not found

        self.startTime = datetime.datetime.strptime(
            datetimestr,
            "%Y/%m/%d %H:%M:%S")  # also timezone at end, e.g. " ET"

        if mg['CURRENCY'] == "$": self.buyinCurrency = "USD"
        elif mg['CURRENCY'] == u"€": self.buyinCurrency = "EUR"
        elif mg['CURRENCY'] in ("SC", "P"): self.buyinCurrency = "PSFP"
        elif not mg['CURRENCY']: self.buyinCurrency = "play"
        if self.buyin == 0: self.buyinCurrency = "FREE"
        self.currency = self.buyinCurrency

        if self.buyinCurrency not in (
                'FREE', 'PSFP') and 'ENTRIES' in mg and self.prizepool == 0:
            self.prizepool = int(Decimal(self.clearMoneyString(
                mg['BUYIN']))) * int(self.entries)

        m = self.re_Player.finditer(self.summaryText)
        for a in m:
            mg = a.groupdict()
            #print "DEBUG: a.groupdict(): %s" % mg
            name = mg['NAME']
            rank = int(mg['RANK'])
            winnings = 0
            rebuyCount = None
            addOnCount = None
            koCount = None
            if len(name) > 0:
                if 'WINNINGS' in mg and mg['WINNINGS'] != None:
                    winnings = int(
                        100 * Decimal(self.clearMoneyString(mg['WINNINGS'])))

                if 'REBUYS' in mg and mg['REBUYS'] != None:
                    rebuyCount = int(mg['REBUYS'])

                if 'ADDONS' in mg and mg['ADDONS'] != None:
                    addOnCount = int(mg['ADDONS'])

                if 'KOS' in mg and mg['KOS'] != None:
                    koCount = int(mg['KOS'])

                if 'CUR' in mg and mg['CUR'] != None:
                    if mg['CUR'] == "$": self.currency = "USD"
                    elif mg['CUR'] == u"€": self.currency = "EUR"
                    elif mg['CUR'] in ("P", "SC"): self.currency = "PSFP"

                if rank == 0:
                    #print "stillplaying"
                    rank = None
                    winnings = None

                if len(name) == 0:
                    print "DEBUG: a.groupdict(): %d %s" % (i, mg)

                #print "DEBUG: addPlayer(%s, %s, %s, %s, None, None, None)" %(rank, name, winnings, self.currency)
                #print "DEBUG: self.buyin: %s self.fee %s" %(self.buyin, self.fee)
                self.addPlayer(rank, name, winnings, self.currency, rebuyCount,
                               addOnCount, koCount)
예제 #14
0
    def parseSummaryFile(self):
        m = self.re_TourneyInfo.search(self.summaryText)
        if m == None:
            tmp = self.summaryText[0:200]
            log.error(_("PokerStarsSummary.parseSummary: '%s'") % tmp)
            raise FpdbParseError

        #print "DEBUG: m.groupdict(): %s" % m.groupdict()

        mg = m.groupdict()
        if 'TOURNO' in mg: self.tourNo = mg['TOURNO']
        if 'LIMIT' in mg and mg['LIMIT'] is not None:
            self.gametype['limitType'] = self.limits[mg['LIMIT']]
        else:
            self.gametype['limitType'] = 'fl'
        if 'GAME' in mg: self.gametype['category'] = self.games[mg['GAME']][1]
        if mg['BUYIN'] != None:
            self.buyin = int(100 * Decimal(self.clearMoneyString(mg['BUYIN'])))
        if mg['FEE'] != None:
            self.fee = int(100 * Decimal(self.clearMoneyString(mg['FEE'])))
        if 'PRIZEPOOL' in mg:
            if mg['PRIZEPOOL'] != None:
                self.prizepool = int(
                    Decimal(self.clearMoneyString(mg['PRIZEPOOL'])))
        if 'ENTRIES' in mg: self.entries = mg['ENTRIES']
        if 'DATETIME' in mg: m1 = self.re_DateTime.finditer(mg['DATETIME'])
        datetimestr = "2000/01/01 00:00:00"  # default used if time not found
        for a in m1:
            datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'), a.group('M'),
                                                 a.group('D'), a.group('H'),
                                                 a.group('MIN'), a.group('S'))

        self.startTime = datetime.datetime.strptime(
            datetimestr,
            "%Y/%m/%d %H:%M:%S")  # also timezone at end, e.g. " ET"
        self.startTime = HandHistoryConverter.changeTimezone(
            self.startTime, "ET", "UTC")

        if mg['CURRENCY'] == "$": self.buyinCurrency = "USD"
        elif mg['CURRENCY'] == u"€": self.buyinCurrency = "EUR"
        elif mg['CURRENCY'] == "FPP": self.buyinCurrency = "PSFP"
        elif not mg['CURRENCY']: self.buyinCurrency = "play"
        if self.buyin == 0: self.buyinCurrency = "FREE"
        self.currency = self.buyinCurrency

        m = self.re_Player.finditer(self.summaryText)
        for a in m:
            mg = a.groupdict()
            #print "DEBUG: a.groupdict(): %s" % mg
            name = mg['NAME']
            rank = int(mg['RANK'])
            winnings = 0
            rebuyCount = 0
            addOnCount = 0
            koCount = 0

            if 'WINNINGS' in mg and mg['WINNINGS'] != None:
                winnings = int(100 * Decimal(mg['WINNINGS']))

            if 'CUR' in mg and mg['CUR'] != None:
                if mg['CUR'] == "$": self.currency = "USD"
                elif mg['CUR'] == u"€": self.currency = "EUR"
                elif mg['CUR'] == "FPP": self.currency = "PSFP"

            if 'STILLPLAYING' in mg and mg['STILLPLAYING'] != None:
                #print "stillplaying"
                rank = None
                winnings = None

            if 'TICKET' and mg['TICKET'] != None:
                #print "Tournament Ticket Level %s" % mg['LEVEL']
                step_values = {
                    '1': '750',  # Step 1 -    $7.50 USD
                    '2': '2750',  # Step 2 -   $27.00 USD
                    '3': '8200',  # Step 3 -   $82.00 USD
                    '4': '21500',  # Step 4 -  $215.00 USD
                    '5': '70000',  # Step 5 -  $700.00 USD
                    '6': '210000',  # Step 6 - $2100.00 USD
                }
                winnings = step_values[mg['LEVEL']]

            #TODO: currency, ko/addon/rebuy count -> need examples!
            #print "DEBUG: addPlayer(%s, %s, %s, %s, None, None, None)" %(rank, name, winnings, self.currency)
            #print "DEBUG: self.buyin: %s self.fee %s" %(self.buyin, self.fee)
            self.addPlayer(rank, name, winnings, self.currency, rebuyCount,
                           addOnCount, koCount)
예제 #15
0
 def readBlinds(self, hand):
     if (hand.gametype['category'],
             hand.gametype['limitType']) == ("badugi", "hp"):
         if hand.gametype['sb'] == None and hand.gametype['bb'] == None:
             hand.gametype['sb'] = "1"
             hand.gametype['bb'] = "2"
     else:
         if hand.gametype['base'] == 'hold':
             street = 'PREFLOP'
         elif hand.gametype['base'] == 'draw':
             street = 'DEAL'
         allinBlinds = {}
         blindsantes = hand.handText.split(street)[0]
         bb, sb = None, None
         for a in self.re_PostSB.finditer(blindsantes):
             #print "DEBUG: found sb: '%s' '%s'" %(self.playerNameFromSeatNo(a.group('PSEAT'), hand), a.group('SB'))
             sb = a.group('SB')
             player = self.playerNameFromSeatNo(a.group('PSEAT'), hand)
             self.adjustMergeTourneyStack(hand, player, sb)
             hand.addBlind(player, 'small blind', sb)
             if not hand.gametype['sb'] or hand.gametype['secondGame']:
                 hand.gametype['sb'] = sb
         for a in self.re_PostBB.finditer(blindsantes):
             #print "DEBUG: found bb: '%s' '%s'" %(self.playerNameFromSeatNo(a.group('PSEAT'), hand), a.group('BB'))
             bb = a.group('BB')
             player = self.playerNameFromSeatNo(a.group('PSEAT'), hand)
             self.adjustMergeTourneyStack(hand, player, bb)
             hand.addBlind(player, 'big blind', bb)
             if not hand.gametype['bb'] or hand.gametype['secondGame']:
                 hand.gametype['bb'] = bb
         for a in self.re_PostBoth.finditer(blindsantes):
             bb = Decimal(self.info['bb'])
             amount = Decimal(a.group('SBBB'))
             player = self.playerNameFromSeatNo(a.group('PSEAT'), hand)
             self.adjustMergeTourneyStack(hand, player, a.group('SBBB'))
             if amount < bb:
                 hand.addBlind(player, 'small blind', a.group('SBBB'))
             elif amount == bb:
                 hand.addBlind(player, 'big blind', a.group('SBBB'))
             else:
                 hand.addBlind(player, 'both', a.group('SBBB'))
         if sb is None or bb is None:
             m = self.re_Action.finditer(blindsantes)
             for action in m:
                 player = self.playerNameFromSeatNo(action.group('PSEAT'),
                                                    hand)
                 #print "DEBUG: found: '%s' '%s'" %(self.playerNameFromSeatNo(action.group('PSEAT'), hand), action.group('BET'))
                 if sb is None:
                     if action.group(
                             'BET') and action.group('BET') != '0.00':
                         sb = action.group('BET')
                         self.adjustMergeTourneyStack(hand, player, sb)
                         hand.addBlind(player, 'small blind', sb)
                         if not hand.gametype['sb'] or hand.gametype[
                                 'secondGame']:
                             hand.gametype['sb'] = sb
                     elif action.group('BET') == '0.00':
                         allinBlinds[player] = 'small blind'
                         #log.error(_(_("MergeToFpdb.readBlinds: Cannot calcualte tourney all-in blind for hand '%s'")) % hand.handid)
                         #raise FpdbParseError
                 elif sb and bb is None:
                     if action.group(
                             'BET') and action.group('BET') != '0.00':
                         bb = action.group('BET')
                         self.adjustMergeTourneyStack(hand, player, bb)
                         hand.addBlind(player, 'big blind', bb)
                         if not hand.gametype['bb'] or hand.gametype[
                                 'secondGame']:
                             hand.gametype['bb'] = bb
                     elif action.group('BET') == '0.00':
                         allinBlinds[player] = 'big blind'
                         #log.error(_(_("MergeToFpdb.readBlinds: Cannot calcualte tourney all-in blind for hand '%s'")) % hand.handid)
                         #raise FpdbParseError
         self.fixTourBlinds(hand, allinBlinds)