mostly spacing cleanup
This commit is contained in:
parent
c91244cdad
commit
465f27af4d
|
@ -67,12 +67,10 @@ class Importer:
|
|||
self.pos_in_file = {} # dict to remember how far we have read in the file
|
||||
#Set defaults
|
||||
self.callHud = self.config.get_import_parameters().get("callFpdbHud")
|
||||
if 'minPrint' not in self.settings:
|
||||
#TODO: Is this value in the xml file?
|
||||
self.settings['minPrint'] = 30
|
||||
if 'handCount' not in self.settings:
|
||||
#TODO: Is this value in the xml file?
|
||||
self.settings['handCount'] = 0
|
||||
|
||||
self.settings.setdefault("minPrint", 30)
|
||||
self.settings.setdefault("handCount", 0)
|
||||
|
||||
self.fdb = fpdb_db.fpdb_db() # sets self.fdb.db self.fdb.cursor and self.fdb.sql
|
||||
self.fdb.do_connect(self.config)
|
||||
|
||||
|
@ -268,7 +266,7 @@ class Importer:
|
|||
starttime = time()
|
||||
last_read_hand = 0
|
||||
loc = 0
|
||||
if (file=="stdin"):
|
||||
if file == "stdin":
|
||||
inputFile = sys.stdin
|
||||
else:
|
||||
if os.path.exists(file):
|
||||
|
@ -308,18 +306,18 @@ class Importer:
|
|||
errors = 0 #counter
|
||||
|
||||
for i in xrange (len(self.lines)): #main loop, iterates through the lines of a file and calls the appropriate parser method
|
||||
if (len(self.lines[i])<2):
|
||||
if len(self.lines[i]) < 2:
|
||||
endpos = i
|
||||
hand = self.lines[startpos:endpos]
|
||||
|
||||
if (len(hand[0])<2):
|
||||
if len(hand[0]) < 2:
|
||||
hand = hand[1:]
|
||||
|
||||
cancelled=False
|
||||
damaged=False
|
||||
if (site=="ftp"):
|
||||
for i in range (len(hand)):
|
||||
if (hand[i].endswith(" has been canceled")): #this is their typo. this is a typo, right?
|
||||
if hand[i].endswith(" has been canceled"): #this is their typo. this is a typo, right?
|
||||
cancelled = True
|
||||
|
||||
#FTP generates lines looking like:
|
||||
|
@ -334,14 +332,14 @@ class Importer:
|
|||
hand.insert(i+1, hand[i][mo.start()+1:])
|
||||
hand[i] = hand[i][0:mo.start()]
|
||||
|
||||
if (len(hand)<3):
|
||||
if len(hand) < 3:
|
||||
pass
|
||||
#todo: the above 2 lines are kind of a dirty hack, the mentioned circumstances should be handled elsewhere but that doesnt work with DOS/Win EOL. actually this doesnt work.
|
||||
elif (hand[0].endswith(" (partial)")): #partial hand - do nothing
|
||||
elif hand[0].endswith(" (partial)"): #partial hand - do nothing
|
||||
partial += 1
|
||||
elif (hand[1].find("Seat")==-1 and hand[2].find("Seat")==-1 and hand[3].find("Seat")==-1):#todo: should this be or instead of and?
|
||||
elif "Seat" not in hand[1] and "Seat" not in hand[2] and "Seat" not in hand[3]:
|
||||
partial += 1
|
||||
elif (cancelled or damaged):
|
||||
elif cancelled or damaged:
|
||||
partial += 1
|
||||
if damaged:
|
||||
print """
|
||||
|
@ -383,16 +381,17 @@ class Importer:
|
|||
#fe.printStackTrace() #todo: get stacktrace
|
||||
self.fdb.db.rollback()
|
||||
|
||||
if (self.settings['failOnError']):
|
||||
if self.settings['failOnError']:
|
||||
self.fdb.db.commit() #dont remove this, in case hand processing was cancelled.
|
||||
raise
|
||||
if (self.settings['minPrint']!=0):
|
||||
if ((stored+duplicates+partial+errors)%self.settings['minPrint']==0):
|
||||
|
||||
if self.settings['minPrint']:
|
||||
if not ((stored+duplicates+partial+errors) % self.settings['minPrint']):
|
||||
print "stored:", stored, "duplicates:", duplicates, "partial:", partial, "errors:", errors
|
||||
|
||||
if (self.settings['handCount']!=0):
|
||||
if self.settings['handCount']:
|
||||
if ((stored+duplicates+partial+errors) >= self.settings['handCount']):
|
||||
if (not self.settings['quiet']):
|
||||
if not self.settings['quiet']:
|
||||
print "quitting due to reaching the amount of hands to be imported"
|
||||
print "Total stored:", stored, "duplicates:", duplicates, "partial/damaged:", partial, "errors:", errors, " time:", (time() - starttime)
|
||||
sys.exit(0)
|
||||
|
@ -400,9 +399,9 @@ class Importer:
|
|||
ttime = time() - starttime
|
||||
print "\rTotal stored:", stored, "duplicates:", duplicates, "partial:", partial, "errors:", errors, " time:", ttime
|
||||
|
||||
if stored==0:
|
||||
if duplicates>0:
|
||||
for line_no in range(len(self.lines)):
|
||||
if not stored:
|
||||
if duplicates:
|
||||
for line_no in xrange(len(self.lines)):
|
||||
if self.lines[line_no].find("Game #")!=-1:
|
||||
final_game_line=self.lines[line_no]
|
||||
handsId=fpdb_simple.parseSiteHandNo(final_game_line)
|
||||
|
|
Loading…
Reference in New Issue
Block a user