From fa3f878c3a7df623513fc1036ac5872fd1afbf64 Mon Sep 17 00:00:00 2001 From: Chaz Date: Wed, 13 Oct 2010 01:51:57 -0400 Subject: [PATCH] * Migrated commandline options to Options.py * Added a EOF exception * Fixed a few error handling issues --- pyfpdb/SplitHandHistory.py | 63 +++++++++++++++----------------------- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/pyfpdb/SplitHandHistory.py b/pyfpdb/SplitHandHistory.py index aa6c2871..8be80e66 100644 --- a/pyfpdb/SplitHandHistory.py +++ b/pyfpdb/SplitHandHistory.py @@ -24,17 +24,20 @@ import os import sys import re import codecs -from optparse import OptionParser +import Options import Configuration +from Exceptions import * from cStringIO import StringIO +(options, argv) = Options.fpdb_options() + __ARCHIVE_PRE_HEADER_REGEX='^Hand #(\d+)\s*$|\*{20}\s#\s\d+\s\*+\s+' re_SplitArchive = re.compile(__ARCHIVE_PRE_HEADER_REGEX) codepage = ["utf-16", "utf-8", "cp1252"] class SplitHandHistory: - def __init__(self, config, in_path = '-', out_path = None, hands = 100, site = "PokerStars", archive = False): + def __init__(self, config, in_path = '-', out_path = None, hands = 100, filter = "PokerStarsToFpdb", archive = False): self.config = config self.in_path = in_path self.out_path = out_path @@ -48,7 +51,6 @@ class SplitHandHistory: self.filedone = False #Acquire re_SplitHands for this hh - filter = self.config.hhcs[site].converter filter_name = filter.replace("ToFpdb", "") mod = __import__(filter) obj = getattr(mod, filter_name, None) @@ -61,22 +63,18 @@ class SplitHandHistory: self.line_delimiter = '\n\n\n' #Add new line addendum for sites which match SplitHand to next line as well - if site == 'OnGame': + if filter_name == 'OnGame': self.line_addendum = '*' - if site == 'Carbon': + if filter_name == 'Carbon': self.line_addendum = '