Merge branch 'master' of git://git.assembla.com/free_poker_tools

This commit is contained in:
Mika Bostrom 2009-08-24 07:36:38 +03:00
commit 59560b1025
2 changed files with 19 additions and 7 deletions

View File

@ -29,7 +29,7 @@ class Fulltilt(HandHistoryConverter):
sitename = "Fulltilt" sitename = "Fulltilt"
filetype = "text" filetype = "text"
codepage = "utf-16" codepage = ["utf-16", "cp1252"]
siteId = 1 # Needs to match id entry in Sites database siteId = 1 # Needs to match id entry in Sites database
# Static regexes # Static regexes

View File

@ -398,6 +398,10 @@ or None if we fail to get the info """
hands = hands + [Hand.Hand(self.sitename, self.gametype, l)] hands = hands + [Hand.Hand(self.sitename, self.gametype, l)]
return hands return hands
def __listof(self, x):
if isinstance(x, list) or isinstance(x, tuple): return x
else: return [x]
def readFile(self): def readFile(self):
"""Open in_path according to self.codepage. Exceptions caught further up""" """Open in_path according to self.codepage. Exceptions caught further up"""
@ -407,12 +411,20 @@ or None if we fail to get the info """
log.debug("Reading stdin with %s" % self.codepage) # is this necessary? or possible? or what? log.debug("Reading stdin with %s" % self.codepage) # is this necessary? or possible? or what?
in_fh = codecs.getreader('cp1252')(sys.stdin) in_fh = codecs.getreader('cp1252')(sys.stdin)
else: else:
in_fh = codecs.open(self.in_path, 'r', self.codepage) success = False
in_fh.seek(self.index) for kodec in self.__listof(self.codepage):
log.debug("Opened in_path: '%s' with %s" % (self.in_path, self.codepage)) if success: break
self.obs = in_fh.read() print "trying", kodec
self.index = in_fh.tell() try:
in_fh.close() in_fh = codecs.open(self.in_path, 'r', kodec)
in_fh.seek(self.index)
log.debug("Opened in_path: '%s' with %s" % (self.in_path, kodec))
self.obs = in_fh.read()
self.index = in_fh.tell()
in_fh.close()
success = True
except:
pass
elif(self.filetype == "xml"): elif(self.filetype == "xml"):
doc = xml.dom.minidom.parse(filename) doc = xml.dom.minidom.parse(filename)
self.doc = doc self.doc = doc