From b27b697ec6bc693d1b65fe722cc04d347df220c5 Mon Sep 17 00:00:00 2001 From: eblade Date: Mon, 27 Jul 2009 14:25:24 -0400 Subject: [PATCH] GuiBulkImport: fix indentation error Hand: fix Pot __str__ to support infinite side pots --- pyfpdb/GuiBulkImport.py | 2 +- pyfpdb/Hand.py | 28 ++++++++-------------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py index 6d0860a8..c9f401ce 100755 --- a/pyfpdb/GuiBulkImport.py +++ b/pyfpdb/GuiBulkImport.py @@ -263,7 +263,7 @@ def main(argv=None): #Do something useful importer = fpdb_import.Importer(False,settings, config) # importer.setDropIndexes("auto") - importer.setDropIndexes("don't drop") + importer.setDropIndexes("don't drop") importer.setFailOnError(options.failOnError) importer.addBulkImportImportFileOrDir(os.path.expanduser(options.filename), site=options.filtername) importer.setCallHud(False) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 6eb1d9b4..4e7d4bdf 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -1323,31 +1323,19 @@ class Pot(object): # Total pot $124.30 Main pot $98.90. Side pot $23.40. | Rake $2 def __str__(self): + if self.sym is None: + self.sym = "C" if self.total is None: print "call Pot.end() before printing pot total" # NB if I'm sure end() is idempotent, call it here. raise FpdbParseError - -# TODO: This really neeads to be a loop to handle multiple side pots - if len(self.pots) == 1: # (only use Total pot) - return "Total pot %s%.2f" % (self.sym, self.total,) - elif len(self.pots) == 2: - return "Total pot %s%.2f Main pot %s%.2f. Side pot %s%2.f." % (self.sym, self.total, self.sym, self.pots[0], self.sym, self.pots[1]) - elif len(self.pots) == 3: - return "Total pot %s%.2f Main pot $%.2f. Side pot-1 %s%2.2f. Side pot-2 %s%.2f." % (self.sym, self.total, self.sym, self.pots[0], self.sym, self.pots[1], self.sym, self.pots[2]) - elif len(self.pots) == 0: - # no small blind and walk in bb (hopefully) - return "Total pot %s%.2f" % (self.sym, self.total,) - else: - return ("too many pots.. no small blind and walk in bb?. self.pots: %s" %(self.pots)) - # I don't know stars format for a walk in the bb when sb doesn't post. - # The thing to do here is raise a Hand error like fpdb import does and file it into errors.txt - - - - - + ret = "Total pot %s%.2f" % (self.sym, self.total) + if len(self.pots) < 2: + return ret; + ret += " Main pot %s%.2f" % (self.sym, self.pots[0]) + + return ret + ''.join([ (" Side pot %s%.2f." % (self.sym, self.pots[x]) ) for x in xrange(1, len(self.pots)) ]) def assemble(cnxn, handid): c = cnxn.cursor()