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

This commit is contained in:
Ray
2009-08-21 19:31:58 -04:00
4 changed files with 809 additions and 35 deletions
+39 -23
View File
@@ -396,29 +396,45 @@ class Importer:
out_path = os.path.join(hhdir, "x"+strftime("%d-%m-%y")+os.path.basename(file))
filter_name = filter.replace("ToFpdb", "")
mod = __import__(filter)
obj = getattr(mod, filter_name, None)
if callable(obj):
hhc = obj(in_path = file, out_path = out_path, index = 0) # Index into file 0 until changeover
if(hhc.getStatus() and self.NEWIMPORT == False):
(stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(db, out_path, site, q)
elif (hhc.getStatus() and self.NEWIMPORT == True):
#This code doesn't do anything yet
handlist = hhc.getProcessedHands()
self.pos_in_file[file] = hhc.getLastCharacterRead()
for hand in handlist:
#hand.prepInsert()
hand.insert(self.database)
else:
# conversion didn't work
# TODO: appropriate response?
return (0, 0, 0, 1, 0, -1)
else:
print "Unknown filter filter_name:'%s' in filter:'%s'" %(filter_name, filter)
return (0, 0, 0, 1, 0, -1)
mod = __import__(filter)
obj = getattr(mod, filter_name, None)
if callable(obj):
hhc = obj(in_path = file, out_path = out_path, index = 0) # Index into file 0 until changeover
if hhc.getParsedObjectType() == "HH":
if(hhc.getStatus() and self.NEWIMPORT == False):
(stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(db, out_path, site, q)
elif (hhc.getStatus() and self.NEWIMPORT == True):
#This code doesn't do anything yet
handlist = hhc.getProcessedHands()
self.pos_in_file[file] = hhc.getLastCharacterRead()
for hand in handlist:
#hand.prepInsert()
hand.insert(self.database)
else:
# conversion didn't work
# TODO: appropriate response?
return (0, 0, 0, 1, 0, -1)
elif hhc.getParsedObjectType() == "Summary":
if(hhc.getStatus()):
tourney = hhc.getTourney()
#print tourney
#tourney.prepInsert()
(stored, duplicates, partial, errors, ttime) = tourney.insert(self.database)
return (stored, duplicates, partial, errors, ttime)
else:
# conversion didn't work
# Could just be the parsing of a non summary file (classic HH file)
return (0, 0, 0, 0, 0)
else:
print "Unknown objects parsed by HHC :'%s'" %(hhc.getObjectTypeRead())
return (0, 0, 0, 1, 0, -1)
else:
print "Unknown filter filter_name:'%s' in filter:'%s'" %(filter_name, filter)
return (0, 0, 0, 1, 0, -1)
#This will barf if conv.getStatus != True
return (stored, duplicates, partial, errors, ttime)