Catch up to Eric - fix markStreets regex

This commit is contained in:
Worros 2009-08-06 11:30:21 +08:00
parent c35132463c
commit a37adde67e
3 changed files with 18 additions and 8 deletions

View File

@ -181,9 +181,9 @@ or None if we fail to get the info """
#m = re.search('(\*\* Dealing down cards \*\*\n)(?P<PREFLOP>.*?\n\*\*)?( Dealing Flop \*\* \[ (?P<FLOP1>\S\S), (?P<FLOP2>\S\S), (?P<FLOP3>\S\S) \])?(?P<FLOP>.*?\*\*)?( Dealing Turn \*\* \[ (?P<TURN1>\S\S) \])?(?P<TURN>.*?\*\*)?( Dealing River \*\* \[ (?P<RIVER1>\S\S) \])?(?P<RIVER>.*)', hand.handText,re.DOTALL) #m = re.search('(\*\* Dealing down cards \*\*\n)(?P<PREFLOP>.*?\n\*\*)?( Dealing Flop \*\* \[ (?P<FLOP1>\S\S), (?P<FLOP2>\S\S), (?P<FLOP3>\S\S) \])?(?P<FLOP>.*?\*\*)?( Dealing Turn \*\* \[ (?P<TURN1>\S\S) \])?(?P<TURN>.*?\*\*)?( Dealing River \*\* \[ (?P<RIVER1>\S\S) \])?(?P<RIVER>.*)', hand.handText,re.DOTALL)
if hand.gametype['base'] == 'hold': if hand.gametype['base'] == 'hold':
m = re.search(r"\*\*\* POCKET CARDS \*\*\*(?P<PREFLOP>.+(?=\*\*\* FLOP \*\*\*)|.+)" m = re.search(r"\*\*\* POCKET CARDS \*\*\*(?P<PREFLOP>.+(?=\*\*\* FLOP \*\*\*)|.+)"
r"\*\*\* FLOP \*\*\*(?P<FLOP>.+(?=\*\*\* TURN \*\*\*)|.+)" r"(\*\*\* FLOP \*\*\*(?P<FLOP>.+(?=\*\*\* TURN \*\*\*)|.+))?"
r"\*\*\* TURN \*\*\*(?P<TURN>.+(?=\*\*\* RIVER \*\*\*)|.+)" r"(\*\*\* TURN \*\*\*(?P<TURN>.+(?=\*\*\* RIVER \*\*\*)|.+))?"
r"\*\*\* RIVER \*\*\*(?P<RIVER>.+)", hand.handText, re.DOTALL) r"(\*\*\* RIVER \*\*\*(?P<RIVER>.+))?", hand.handText, re.DOTALL)
elif hand.gametype['base'] == 'stud': # TODO: Not implemented yet elif hand.gametype['base'] == 'stud': # TODO: Not implemented yet
m = re.search(r"(?P<ANTES>.+(?=\*\* Dealing down cards \*\*)|.+)" m = re.search(r"(?P<ANTES>.+(?=\*\* Dealing down cards \*\*)|.+)"
@ -201,7 +201,7 @@ or None if we fail to get the info """
logging.debug("readCommunityCards (%s)" % street) logging.debug("readCommunityCards (%s)" % street)
m = self.re_Board.search(hand.streets[street]) m = self.re_Board.search(hand.streets[street])
cards = m.group('CARDS') cards = m.group('CARDS')
cards = [card.strip() for card in cards.split(',')] cards = [validCard(card) for card in cards.split(' ')]
hand.setCommunityCards(street=street, cards=cards) hand.setCommunityCards(street=street, cards=cards)
def readAntes(self, hand): def readAntes(self, hand):
@ -241,7 +241,7 @@ or None if we fail to get the info """
# "2c, qh" -> ["2c","qc"] # "2c, qh" -> ["2c","qc"]
# Also works with Omaha hands. # Also works with Omaha hands.
cards = m.group('CARDS') cards = m.group('CARDS')
cards = [card.strip() for card in cards.split(',')] cards = [validCard(card) for card in cards.split(' ')]
# hand.addHoleCards(cards, m.group('PNAME')) # hand.addHoleCards(cards, m.group('PNAME'))
hand.addHoleCards('PREFLOP', hand.hero, closed=cards, shown=False, mucked=False, dealt=True) hand.addHoleCards('PREFLOP', hand.hero, closed=cards, shown=False, mucked=False, dealt=True)
@ -283,7 +283,7 @@ or None if we fail to get the info """
logging.debug("readShowdownActions") logging.debug("readShowdownActions")
for shows in self.re_ShowdownAction.finditer(hand.handText): for shows in self.re_ShowdownAction.finditer(hand.handText):
cards = shows.group('CARDS') cards = shows.group('CARDS')
cards = cards.split(', ') cards = [validCard(card) for card in cards.split(' ')]
logging.debug("readShowdownActions %s %s" %(cards, shows.group('PNAME'))) logging.debug("readShowdownActions %s %s" %(cards, shows.group('PNAME')))
hand.addShownCards(cards, shows.group('PNAME')) hand.addShownCards(cards, shows.group('PNAME'))
@ -298,7 +298,7 @@ or None if we fail to get the info """
try: try:
if m.group('CARDS') is not None: if m.group('CARDS') is not None:
cards = m.group('CARDS') cards = m.group('CARDS')
cards = cards.split(', ') cards = [validCard(card) for card in cards.split(' ')]
player = m.group('PNAME') player = m.group('PNAME')
logging.debug("readShownCards %s cards=%s" % (player, cards)) logging.debug("readShownCards %s cards=%s" % (player, cards))
# hand.addShownCards(cards=None, player=m.group('PNAME'), holeandboard=cards) # hand.addShownCards(cards=None, player=m.group('PNAME'), holeandboard=cards)
@ -306,6 +306,13 @@ or None if we fail to get the info """
except IndexError: except IndexError:
pass # there's no "PLAYER - Mucks" at AP that I can see pass # there's no "PLAYER - Mucks" at AP that I can see
def validCard(card):
card = card.strip()
if card == '10s': card = 'Ts'
if card == '10h': card = 'Th'
if card == '10d': card = 'Td'
if card == '10c': card = 'Tc'
return card
if __name__ == "__main__": if __name__ == "__main__":
parser = OptionParser() parser = OptionParser()

View File

@ -60,7 +60,7 @@ class HandHistoryConverter():
out_dir = os.path.dirname(self.out_path) out_dir = os.path.dirname(self.out_path)
if not os.path.isdir(out_dir): if not os.path.isdir(out_dir):
logging.info("Creatin directory '%s'" % out_dir) logging.info("Creatin directory '%s'" % out_dir)
# os.makedirs(out_dir) os.makedirs(out_dir)
self.out_fh = open(self.out_path, 'w') self.out_fh = open(self.out_path, 'w')
self.sitename = sitename self.sitename = sitename

View File

@ -130,6 +130,9 @@ class Importer:
# self.updated = time() # self.updated = time()
def clearFileList(self): def clearFileList(self):
self.updatedsize = {}
self.updatetime = {}
self.pos_in_file = {}
self.filelist = {} self.filelist = {}
def closeDBs(self): def closeDBs(self):