Merge branch 'carl'
This commit is contained in:
		
						commit
						1b4b335b29
					
				| 
						 | 
				
			
			@ -42,10 +42,10 @@ class Absolute(HandHistoryConverter):
 | 
			
		|||
#Seat 6 - FETS63 ($0.75 in chips)
 | 
			
		||||
#Board [10s 5d Kh Qh 8c]
 | 
			
		||||
 | 
			
		||||
    re_GameInfo     = re.compile(ur"^Stage #([0-9]+): (?P<GAME>Holdem|HORSE)(?: \(1 on 1\)|)?  ?(?P<LIMIT>No Limit|Pot Limit|Normal|)? ?(?P<CURRENCY>\$| €|)(?P<SB>[.0-9]+)/?(?:\$| €|)(?P<BB>[.0-9]+)?", re.MULTILINE)
 | 
			
		||||
    re_GameInfo     = re.compile(ur"^Stage #(C?[0-9]+): (?P<GAME>Holdem|HORSE)(?: \(1 on 1\)|)?  ?(?P<LIMIT>No Limit|Pot Limit|Normal|)? ?(?P<CURRENCY>\$| €|)(?P<SB>[.0-9]+)/?(?:\$| €|)(?P<BB>[.0-9]+)?", re.MULTILINE)
 | 
			
		||||
    re_HorseGameInfo = re.compile(ur"^Game Type: (?P<LIMIT>Limit) (?P<GAME>Holdem)", re.MULTILINE)
 | 
			
		||||
    # TODO: can set max seats via (1 on 1) to a known 2 .. 
 | 
			
		||||
    re_HandInfo     = re.compile(ur"^Stage #(?P<HID>[0-9]+): .*(?P<DATETIME>\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d).*\n(Table: (?P<TABLE>.*) \(Real Money\))?", re.MULTILINE)
 | 
			
		||||
    re_HandInfo     = re.compile(ur"^Stage #C?(?P<HID>[0-9]+): .*(?P<DATETIME>\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d).*\n(Table: (?P<TABLE>.*) \(Real Money\))?", re.MULTILINE)
 | 
			
		||||
    re_TableFromFilename = re.compile(ur".*IHH([0-9]+) (?P<TABLE>.*) -") # on HORSE STUD games, the table name isn't in the hand info!
 | 
			
		||||
    re_Button       = re.compile(ur"Seat #(?P<BUTTON>[0-9]) is the ?[dead]* dealer$", re.MULTILINE) # TODO: that's not the right way to match for "dead" dealer is it?
 | 
			
		||||
    re_PlayerInfo   = re.compile(ur"^Seat (?P<SEAT>[0-9]) - (?P<PNAME>.*) \((?:\$| €|)(?P<CASH>[0-9]*[.0-9]+) in chips\)", re.MULTILINE)
 | 
			
		||||
| 
						 | 
				
			
			@ -96,17 +96,18 @@ class Absolute(HandHistoryConverter):
 | 
			
		|||
 | 
			
		||||
    def determineGameType(self, handText):
 | 
			
		||||
        """return dict with keys/values:
 | 
			
		||||
    'type'       in ('ring', 'tour')
 | 
			
		||||
    'limitType'  in ('nl', 'cn', 'pl', 'cp', 'fl')
 | 
			
		||||
    'base'       in ('hold', 'stud', 'draw')
 | 
			
		||||
    'category'   in ('holdem', 'omahahi', omahahilo', 'razz', 'studhi', 'studhilo', 'fivedraw', '27_1draw', '27_3draw', 'badugi')
 | 
			
		||||
    'hilo'       in ('h','l','s')
 | 
			
		||||
    'smallBlind' int?
 | 
			
		||||
    'bigBlind'   int?
 | 
			
		||||
    'smallBet'
 | 
			
		||||
    'bigBet'
 | 
			
		||||
    'currency'  in ('USD', 'EUR', 'T$', <countrycode>)
 | 
			
		||||
or None if we fail to get the info """
 | 
			
		||||
        'type'       in ('ring', 'tour')
 | 
			
		||||
        'limitType'  in ('nl', 'cn', 'pl', 'cp', 'fl')
 | 
			
		||||
        'base'       in ('hold', 'stud', 'draw')
 | 
			
		||||
        'category'   in ('holdem', 'omahahi', omahahilo', 'razz', 'studhi', 'studhilo', 'fivedraw', '27_1draw', '27_3draw', 'badugi')
 | 
			
		||||
        'hilo'       in ('h','l','s')
 | 
			
		||||
        'smallBlind' int?
 | 
			
		||||
        'bigBlind'   int?
 | 
			
		||||
        'smallBet'
 | 
			
		||||
        'bigBet'
 | 
			
		||||
        'currency'  in ('USD', 'EUR', 'T$', <countrycode>)
 | 
			
		||||
 | 
			
		||||
        or None if we fail to get the info """
 | 
			
		||||
        info = {'type':'ring'}
 | 
			
		||||
        
 | 
			
		||||
        m = self.re_GameInfo.search(handText)
 | 
			
		||||
| 
						 | 
				
			
			@ -329,6 +330,9 @@ def validCard(card):
 | 
			
		|||
    return card
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    import Configuration
 | 
			
		||||
    config =  Configuration.Config(None)
 | 
			
		||||
 | 
			
		||||
    parser = OptionParser()
 | 
			
		||||
    parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="-")
 | 
			
		||||
    parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
 | 
			
		||||
| 
						 | 
				
			
			@ -345,5 +349,5 @@ if __name__ == "__main__":
 | 
			
		|||
    LOG_FILENAME = './logging.out'
 | 
			
		||||
    logging.basicConfig(filename=LOG_FILENAME,level=options.verbosity)
 | 
			
		||||
 | 
			
		||||
    e = Absolute(in_path = options.ipath, out_path = options.opath, follow = options.follow, autostart=True, debugging=True)
 | 
			
		||||
    e = Absolute(config, in_path = options.ipath, out_path = options.opath, follow = options.follow, autostart=True)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1994,7 +1994,7 @@ class Database:
 | 
			
		|||
            #print "the query:",self.sql.query['getTourneyTypeId'].replace('%s', self.sql.query['placeholder'])
 | 
			
		||||
            cursor.execute (self.sql.query['getTourneyTypeId'].replace('%s', self.sql.query['placeholder']), 
 | 
			
		||||
                            (hand.siteId, hand.buyinCurrency, hand.buyin, hand.fee, hand.gametype['category'], hand.gametype['limitType'], hand.isKO,
 | 
			
		||||
                             hand.isRebuy, hand.isAddOn, hand.speed, hand.isShootout, hand.isMatrix)
 | 
			
		||||
                             hand.isRebuy, hand.isAddOn, hand.speed, hand.isShootout, hand.isMatrix) #TODO: add koamount
 | 
			
		||||
                            )
 | 
			
		||||
            result=cursor.fetchone()
 | 
			
		||||
            #print "result of fetching TT by details:",result
 | 
			
		||||
| 
						 | 
				
			
			@ -2003,8 +2003,8 @@ class Database:
 | 
			
		|||
                tourneyTypeId = result[0]
 | 
			
		||||
            except TypeError: #this means we need to create a new entry
 | 
			
		||||
                cursor.execute (self.sql.query['insertTourneyType'].replace('%s', self.sql.query['placeholder']),
 | 
			
		||||
                                (hand.siteId, hand.buyinCurrency, hand.buyin, hand.fee, hand.gametype['category'], hand.gametype['limitType'], hand.buyInChips,
 | 
			
		||||
                                 hand.isKO, hand.isRebuy,
 | 
			
		||||
                                (hand.siteId, hand.buyinCurrency, hand.buyin, hand.fee, hand.gametype['category'], hand.gametype['limitType'],
 | 
			
		||||
                                 hand.buyInChips, hand.isKO, hand.koBounty, hand.isRebuy,
 | 
			
		||||
                                 hand.isAddOn, hand.speed, hand.isShootout, hand.isMatrix, hand.added, hand.addedCurrency)
 | 
			
		||||
                                )
 | 
			
		||||
                tourneyTypeId = self.get_last_insert_id(cursor)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -289,8 +289,10 @@ class DerivedStats():
 | 
			
		|||
#        actions = hand.actions[hand.actionStreets[-1]]
 | 
			
		||||
#        print "p_actions:", self.pfba(actions), "p_folds:", self.pfba(actions, l=('folds',)), "alliners:", alliners
 | 
			
		||||
#        pas = set.union(self.pfba(actions) - self.pfba(actions, l=('folds',)),  alliners)
 | 
			
		||||
        
 | 
			
		||||
        p_in = set(x[1] for x in hand.players)
 | 
			
		||||
 | 
			
		||||
        # hand.players includes people that are sitting out on some sites. 
 | 
			
		||||
        # Those that posted an ante should have been deal cards. 
 | 
			
		||||
        p_in = set([x[0] for x in hand.actions['BLINDSANTES']]) 
 | 
			
		||||
        for (i, street) in enumerate(hand.actionStreets):
 | 
			
		||||
            actions = hand.actions[street]
 | 
			
		||||
            p_in = p_in - self.pfba(actions, l=('folds',))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -83,6 +83,7 @@ class Hand(object):
 | 
			
		|||
        self.isRebuy = False
 | 
			
		||||
        self.isAddOn = False
 | 
			
		||||
        self.isKO = False
 | 
			
		||||
        self.koBounty = None
 | 
			
		||||
        self.isMatrix = False
 | 
			
		||||
        self.isShootout = False
 | 
			
		||||
        self.added = None
 | 
			
		||||
| 
						 | 
				
			
			@ -168,6 +169,7 @@ class Hand(object):
 | 
			
		|||
                 ("IS REBUY", self.isRebuy),
 | 
			
		||||
                 ("IS ADDON", self.isAddOn),
 | 
			
		||||
                 ("IS KO", self.isKO),
 | 
			
		||||
                 ("KO BOUNTY", self.koBounty),
 | 
			
		||||
                 ("IS MATRIX", self.isMatrix),
 | 
			
		||||
                 ("IS SHOOTOUT", self.isShootout),
 | 
			
		||||
                 ("TOURNEY COMMENT", self.tourneyComment),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,7 +72,7 @@ class PokerStars(HandHistoryConverter):
 | 
			
		|||
          (Tournament\s\#                # open paren of tournament info
 | 
			
		||||
          (?P<TOURNO>\d+),\s
 | 
			
		||||
          # here's how I plan to use LS
 | 
			
		||||
          (?P<BUYIN>([%(LS)s\+\d\.]+\s?(?P<TOUR_ISO>%(LEGAL_ISO)s)?)|Freeroll)\s+)?                          
 | 
			
		||||
          (?P<BUYIN>(?P<BIAMT>[%(LS)s\d\.]+)\+(?P<BOUNTY>[%(LS)s\d\.]+)?\+?(?P<BIRAKE>[%(LS)s\d\.]+)\s?(?P<TOUR_ISO>%(LEGAL_ISO)s)|Freeroll)\s+)?
 | 
			
		||||
          # close paren of tournament info
 | 
			
		||||
          (?P<MIXED>HORSE|8\-Game|HOSE)?\s?\(?
 | 
			
		||||
          (?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
 | 
			
		||||
| 
						 | 
				
			
			@ -206,24 +206,20 @@ class PokerStars(HandHistoryConverter):
 | 
			
		|||
        m = self.re_HandInfo.search(hand.handText,re.DOTALL)
 | 
			
		||||
        if m:
 | 
			
		||||
            info.update(m.groupdict())
 | 
			
		||||
#                hand.maxseats = int(m2.group(1))
 | 
			
		||||
        else:
 | 
			
		||||
            pass  # throw an exception here, eh?
 | 
			
		||||
        m = self.re_GameInfo.search(hand.handText)
 | 
			
		||||
        if m:
 | 
			
		||||
            info.update(m.groupdict())
 | 
			
		||||
#        m = self.re_Button.search(hand.handText)
 | 
			
		||||
#        if m: info.update(m.groupdict()) 
 | 
			
		||||
        # TODO : I rather like the idea of just having this dict as hand.info
 | 
			
		||||
 | 
			
		||||
        log.debug("readHandInfo: %s" % 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/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])
 | 
			
		||||
                # m2 = re.search("(?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]+)", info[key])
 | 
			
		||||
                datetimestr = "2000/01/01 00:00:00"  # default used if time not found (stops import crashing, but startTime will be wrong)
 | 
			
		||||
                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??
 | 
			
		||||
| 
						 | 
				
			
			@ -236,12 +232,15 @@ class PokerStars(HandHistoryConverter):
 | 
			
		|||
                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:
 | 
			
		||||
                        #print "info[key]:",info[key]
 | 
			
		||||
                        if info[key].find("$")!=-1:
 | 
			
		||||
                            hand.buyinCurrency="USD"
 | 
			
		||||
                        elif info[key].find(u"€")!=-1:
 | 
			
		||||
| 
						 | 
				
			
			@ -249,14 +248,18 @@ class PokerStars(HandHistoryConverter):
 | 
			
		|||
                        elif info[key].find("FPP")!=-1:
 | 
			
		||||
                            hand.buyinCurrency="PSFP"
 | 
			
		||||
                        else:
 | 
			
		||||
                            raise FpdbParseError("failed to detect currency") #FIXME: handle other currencies, FPP, play money
 | 
			
		||||
                            #FIXME: handle other currencies, FPP, play money
 | 
			
		||||
                            raise FpdbParseError("failed to detect currency")
 | 
			
		||||
                        
 | 
			
		||||
                        if hand.buyinCurrency=="USD" or hand.buyinCurrency=="EUR":
 | 
			
		||||
                            info[key]=info[key][:-4]
 | 
			
		||||
                            middle=info[key].find("+")
 | 
			
		||||
                            hand.buyin = int(100*Decimal(info[key][1:middle]))
 | 
			
		||||
                            hand.fee = int(100*Decimal(info[key][middle+2:]))
 | 
			
		||||
                        elif hand.buyinCurrency=="PSFP":
 | 
			
		||||
                        if hand.buyinCurrency!="PSFP":
 | 
			
		||||
                            hand.buyin = int(100*Decimal(info['BIAMT'][1:]))
 | 
			
		||||
                            if info['BIRAKE']=="0": #we have a non-bounty game
 | 
			
		||||
                                hand.fee = int(100*Decimal(info['BOUNTY'][1:]))
 | 
			
		||||
                            else:
 | 
			
		||||
                                hand.fee = int(100*Decimal(info['BIRAKE'][1:]))
 | 
			
		||||
                                hand.isKO = True
 | 
			
		||||
                                hand.koBounty = int(100*Decimal(info['BOUNTY'][1:]))
 | 
			
		||||
                        else:
 | 
			
		||||
                            hand.buyin = int(Decimal(info[key][0:-3]))
 | 
			
		||||
                            hand.fee = 0
 | 
			
		||||
            if key == 'LEVEL':
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3786,9 +3786,9 @@ class Sql:
 | 
			
		|||
        """
 | 
			
		||||
 | 
			
		||||
        self.query['insertTourneyType'] = """INSERT INTO TourneyTypes
 | 
			
		||||
                                                  (siteId, currency, buyin, fee, category, limitType, buyInChips, knockout, rebuy,
 | 
			
		||||
                                                  (siteId, currency, buyin, fee, category, limitType, buyInChips, knockout, koBounty, rebuy,
 | 
			
		||||
                                                  addOn ,speed, shootout, matrix, added, addedCurrency)
 | 
			
		||||
                                              VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
 | 
			
		||||
                                              VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
        self.query['getTourneyByTourneyNo'] = """SELECT t.*
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -70,7 +70,7 @@ class Table(Table_Window):
 | 
			
		|||
        for listing in os.popen('xwininfo -root -tree').readlines():
 | 
			
		||||
            if re.search(search_string, listing):
 | 
			
		||||
#                print listing
 | 
			
		||||
                mo = re.match('\s+([\dxabcdef]+) (.+):\s\(\"([a-zA-Z.]+)\".+  (\d+)x(\d+)\+\d+\+\d+  \+(\d+)\+(\d+)', listing)
 | 
			
		||||
                mo = re.match('\s+([\dxabcdef]+) (.+):\s\(\"([a-zA-Z0-9\-.]+)\".+  (\d+)x(\d+)\+\d+\+\d+  \+(\d+)\+(\d+)', listing)
 | 
			
		||||
                self.number = int( mo.group(1), 0)
 | 
			
		||||
                self.width  = int( mo.group(4) )
 | 
			
		||||
                self.height = int( mo.group(5) )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user