From 73e6666cbc77289727a7f7f944994fddc344616d Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 30 Jul 2009 11:40:16 +0800 Subject: [PATCH 1/2] Add auto folder creation to HHC Contributed by grindi on 2+2 http://forumserver.twoplustwo.com/showpost.php?p=12156328&postcount=1666 Creates the sub folders of hhArchiveBase for placing the converted files in. --- pyfpdb/HandHistoryConverter.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index f5d46034..2ded2c50 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -57,6 +57,10 @@ class HandHistoryConverter(): self.out_fh = sys.stdout else: # TODO: out_path should be sanity checked. + out_dir = os.path.dirname(self.out_path) + if not os.path.isdir(out_dir): + logging.info("Creatin directory '%s'" % out_dir) + os.makedirs(out_dir) self.out_fh = open(self.out_path, 'w') self.sitename = sitename From 68ac5ff5544e87e899f710f18ba69d51dd452aaa Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 30 Jul 2009 12:13:45 +0800 Subject: [PATCH 2/2] Q&D hack to fix FTP file reads after update Contributed by grindi on 2+2 http://forumserver.twoplustwo.com/showpost.php?p=12156328&postcount=166 Removes u'\xff\xfe' from the end of file if they exist. --- pyfpdb/FulltiltToFpdb.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index 4fb0e8b3..3b8026bf 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -118,7 +118,7 @@ follow : whether to tail -f the input""" if not m: return None mg = m.groupdict() - + # translations from captured groups to our info strings limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl' } games = { # base, category @@ -142,6 +142,24 @@ follow : whether to tail -f the input""" # NB: SB, BB must be interpreted as blinds or bets depending on limit type. return info + #Following function is a hack, we should be dealing with this in readFile (i think correct codepage....) + # Same function as parent class, removing the 2 end characters. - CG + def allHandsAsList(self): + """Return a list of handtexts in the file at self.in_path""" + #TODO : any need for this to be generator? e.g. stars support can email one huge file of all hands in a year. Better to read bit by bit than all at once. + self.readFile() + + # FIXME: it's a hack + if self.obs[:2] == u'\xff\xfe': + self.obs = self.obs[2:].replace('\x00', '') + + self.obs = self.obs.strip() + self.obs = self.obs.replace('\r\n', '\n') + if self.obs == "" or self.obs == None: + logging.info("Read no hands.") + return + return re.split(self.re_SplitHands, self.obs) + def readHandInfo(self, hand): m = self.re_HandInfo.search(hand.handText,re.DOTALL) if(m == None):