From 8009281e5a28ed727b95e67532e3cd29663bdfcf Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 18 Mar 2009 12:32:34 -0400 Subject: [PATCH] More fixing of import options. --- pyfpdb/Configuration.py | 11 +++++++++-- pyfpdb/fpdb_save_to_db.py | 40 ++++++++------------------------------- 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index c113f9db..81645694 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -32,6 +32,13 @@ import shutil import xml.dom.minidom from xml.dom.minidom import Node +def fix_tf(x): + if x == "1" or x == 1 or string.lower(x) == "true" or string.lower(x) == "t": + return True + if x == "0" or x == 0 or string.lower(x) == "false" or string.lower(x) == "f": + return False + return False + class Layout: def __init__(self, node): @@ -206,11 +213,11 @@ class Import: self.callFpdbHud = node.getAttribute("callFpdbHud") self.hhArchiveBase = node.getAttribute("hhArchiveBase") if node.hasAttribute("saveActions"): - self.saveActions = node.getAttribute("saveActions") + self.saveActions = fix_tf(node.getAttribute("saveActions")) else: self.saveActions = True if node.hasAttribute("fastStoreHudCache"): - self.fastStoreHudCache = node.getAttribute("fastStoreHudCache") + self.fastStoreHudCache = fix_tf(node.getAttribute("fastStoreHudCache")) else: self.fastStoreHudCache = False diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index b215f7ee..68c11833 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -40,14 +40,8 @@ def ring_stud(config, backend, db, cursor, base, category, site_hand_no, gametyp ,seatNos): import_options = config.get_import_parameters() - if import_options['saveActions'] == 'True': - saveActions = True - else: - saveActions = False - if import_options['fastStoreHudCache'] == 'True': - fastStoreHudCache = True - else: - fastStoreHudCache = False + saveActions = import_options['saveActions'] + fastStoreHudCache = import_options['fastStoreHudCache'] fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) @@ -74,14 +68,8 @@ def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no, """stores a holdem/omaha hand into the database""" import_options = config.get_import_parameters() - if import_options['saveActions'] == 'True': - saveActions = True - else: - saveActions = False - if import_options['fastStoreHudCache'] == 'True': - fastStoreHudCache = True - else: - fastStoreHudCache = False + saveActions = import_options['saveActions'] + fastStoreHudCache = import_options['fastStoreHudCache'] t0 = time() fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) @@ -121,14 +109,8 @@ def tourney_holdem_omaha(config, backend, db, cursor, base, category, siteTourne """stores a tourney holdem/omaha hand into the database""" import_options = config.get_import_parameters() - if import_options['saveActions'] == 'True': - saveActions = True - else: - saveActions = False - if import_options['fastStoreHudCache'] == 'True': - fastStoreHudCache = True - else: - fastStoreHudCache = False + saveActions = import_options['saveActions'] + fastStoreHudCache = import_options['fastStoreHudCache'] fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) fpdb_simple.fill_board_cards(board_values, board_suits) @@ -164,14 +146,8 @@ def tourney_stud(config, backend, db, cursor, base, category, siteTourneyNo, buy #stores a tourney stud/razz hand into the database import_options = config.get_import_parameters() - if import_options['saveActions'] == 'True': - saveActions = True - else: - saveActions = False - if import_options['fastStoreHudCache'] == 'True': - fastStoreHudCache = True - else: - fastStoreHudCache = False + saveActions = import_options['saveActions'] + fastStoreHudCache = import_options['fastStoreHudCache'] fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits)