filterCrap after checking if hand is in db
refactor GuiBulkImport : add main() so that it can be called from interactive shell (for profiling purposes).
This commit is contained in:
parent
451a9b3ab1
commit
239330ae7b
|
@ -45,7 +45,7 @@ class GuiAutoImport (threading.Thread):
|
||||||
|
|
||||||
self.importer = fpdb_import.Importer(self,self.settings, self.config)
|
self.importer = fpdb_import.Importer(self,self.settings, self.config)
|
||||||
self.importer.setCallHud(True)
|
self.importer.setCallHud(True)
|
||||||
self.importer.setMinPrint(30)
|
self.importer.setMinPrint(settings['minPrint'])
|
||||||
self.importer.setQuiet(False)
|
self.importer.setQuiet(False)
|
||||||
self.importer.setFailOnError(False)
|
self.importer.setFailOnError(False)
|
||||||
self.importer.setHandCount(0)
|
self.importer.setHandCount(0)
|
||||||
|
@ -227,13 +227,15 @@ if __name__== "__main__":
|
||||||
|
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
parser.add_option("-q", "--quiet", action="store_false", dest="gui", default=True, help="don't start gui")
|
parser.add_option("-q", "--quiet", action="store_false", dest="gui", default=True, help="don't start gui")
|
||||||
|
parser.add_option("-m", "--minPrint", "--status", dest="minPrint", default="0", type="int",
|
||||||
|
help="How often to print a one-line status report (0 (default) means never)")
|
||||||
(options, sys.argv) = parser.parse_args()
|
(options, sys.argv) = parser.parse_args()
|
||||||
|
|
||||||
config = Configuration.Config()
|
config = Configuration.Config()
|
||||||
# db = fpdb_db.fpdb_db()
|
# db = fpdb_db.fpdb_db()
|
||||||
|
|
||||||
settings = {}
|
settings = {}
|
||||||
|
settings['minPrint'] = options.minPrint
|
||||||
if os.name == 'nt': settings['os'] = 'windows'
|
if os.name == 'nt': settings['os'] = 'windows'
|
||||||
else: settings['os'] = 'linuxmac'
|
else: settings['os'] = 'linuxmac'
|
||||||
|
|
||||||
|
|
|
@ -204,29 +204,36 @@ class GuiBulkImport():
|
||||||
self.cb_dropindexes.set_sensitive(False)
|
self.cb_dropindexes.set_sensitive(False)
|
||||||
self.lab_drop.set_sensitive(False)
|
self.lab_drop.set_sensitive(False)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main(argv=None):
|
||||||
|
"""main can also be called in the python interpreter, by supplying the command line as the argument.
|
||||||
|
>>>import GuiBulkImport
|
||||||
|
>>>GuiBulkImport.main("-f ~/data/hands")"""
|
||||||
|
if argv is None:
|
||||||
|
argv = sys.argv[1:]
|
||||||
|
else:
|
||||||
|
argv = argv.split(" ")
|
||||||
|
|
||||||
def destroy(*args): # call back for terminating the main eventloop
|
def destroy(*args): # call back for terminating the main eventloop
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
parser.add_option("-f", "--file", dest="filename", metavar="FILE",
|
parser.add_option("-f", "--file", dest="filename", metavar="FILE", default=None,
|
||||||
help="Input file in quiet mode")
|
help="Input file in quiet mode")
|
||||||
parser.add_option("-q", "--quiet", action="store_false", dest="gui", default=True,
|
parser.add_option("-q", "--quiet", action="store_false", dest="gui", default=True,
|
||||||
help="don't start gui")
|
help="don't start gui; deprecated (just give a filename with -f).")
|
||||||
parser.add_option("-c", "--convert", dest="filtername", default="passthrough", metavar="FILTER",
|
parser.add_option("-c", "--convert", dest="filtername", default="passthrough", metavar="FILTER",
|
||||||
help="Conversion filter (*passthrough, FullTiltToFpdb, PokerStarsToFpdb, EverleafToFpdb)")
|
help="Conversion filter (*passthrough, FullTiltToFpdb, PokerStarsToFpdb, EverleafToFpdb)")
|
||||||
parser.add_option("-x", "--failOnError", action="store_true", default=False,
|
parser.add_option("-x", "--failOnError", action="store_true", default=False,
|
||||||
help="If this option is passed it quits when it encounters any error")
|
help="If this option is passed it quits when it encounters any error")
|
||||||
#parser.add_option("-m", "--minPrint", "--status", default="0", type="int",
|
parser.add_option("-m", "--minPrint", "--status", dest="minPrint", default="0", type="int",
|
||||||
#help="How often to print a one-line status report (0 (default) means never)")
|
help="How often to print a one-line status report (0 (default) means never)")
|
||||||
(options, sys.argv) = parser.parse_args()
|
(options, sys.argv) = parser.parse_args(args = argv)
|
||||||
|
|
||||||
config = Configuration.Config()
|
config = Configuration.Config()
|
||||||
db = fpdb_db.fpdb_db()
|
db = fpdb_db.fpdb_db()
|
||||||
|
|
||||||
settings = {}
|
settings = {}
|
||||||
|
settings['minPrint'] = options.minPrint
|
||||||
if os.name == 'nt': settings['os'] = 'windows'
|
if os.name == 'nt': settings['os'] = 'windows'
|
||||||
else: settings['os'] = 'linuxmac'
|
else: settings['os'] = 'linuxmac'
|
||||||
|
|
||||||
|
@ -235,7 +242,10 @@ if __name__ == '__main__':
|
||||||
settings.update(config.get_import_parameters())
|
settings.update(config.get_import_parameters())
|
||||||
settings.update(config.get_default_paths())
|
settings.update(config.get_default_paths())
|
||||||
|
|
||||||
if(options.gui == True):
|
if not options.gui:
|
||||||
|
print """-q is deprecated. Just use "-f filename" instead"""
|
||||||
|
# This is because -q on its own causes an error, so -f is necessary and sufficient for cmd line use
|
||||||
|
if not options.filename:
|
||||||
i = GuiBulkImport(db, settings, config)
|
i = GuiBulkImport(db, settings, config)
|
||||||
main_window = gtk.Window()
|
main_window = gtk.Window()
|
||||||
main_window.connect('destroy', destroy)
|
main_window.connect('destroy', destroy)
|
||||||
|
@ -247,7 +257,12 @@ if __name__ == '__main__':
|
||||||
importer = fpdb_import.Importer(False,settings, config)
|
importer = fpdb_import.Importer(False,settings, config)
|
||||||
importer.setDropIndexes("auto")
|
importer.setDropIndexes("auto")
|
||||||
importer.setFailOnError(options.failOnError)
|
importer.setFailOnError(options.failOnError)
|
||||||
importer.addBulkImportImportFileOrDir(options.filename, filter=options.filtername)
|
importer.addBulkImportImportFileOrDir(os.path.expanduser(options.filename), filter=options.filtername)
|
||||||
importer.setCallHud(False)
|
importer.setCallHud(False)
|
||||||
importer.runImport()
|
importer.runImport()
|
||||||
importer.clearFileList()
|
importer.clearFileList()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,7 @@ class Importer:
|
||||||
# Called from GuiBulkImport to add a file or directory.
|
# Called from GuiBulkImport to add a file or directory.
|
||||||
def addBulkImportImportFileOrDir(self, inputPath,filter = "passthrough"):
|
def addBulkImportImportFileOrDir(self, inputPath,filter = "passthrough"):
|
||||||
"""Add a file or directory for bulk import"""
|
"""Add a file or directory for bulk import"""
|
||||||
|
|
||||||
# Bulk import never monitors
|
# Bulk import never monitors
|
||||||
# if directory, add all files in it. Otherwise add single file.
|
# if directory, add all files in it. Otherwise add single file.
|
||||||
# TODO: only add sane files?
|
# TODO: only add sane files?
|
||||||
|
@ -124,7 +125,6 @@ class Importer:
|
||||||
self.addImportFile(os.path.join(inputPath, subdir[0], file), site="default", filter=filter)
|
self.addImportFile(os.path.join(inputPath, subdir[0], file), site="default", filter=filter)
|
||||||
else:
|
else:
|
||||||
self.addImportFile(inputPath, site="default", filter=filter)
|
self.addImportFile(inputPath, site="default", filter=filter)
|
||||||
|
|
||||||
#Add a directory of files to filelist
|
#Add a directory of files to filelist
|
||||||
#Only one import directory per site supported.
|
#Only one import directory per site supported.
|
||||||
#dirlist is a hash of lists:
|
#dirlist is a hash of lists:
|
||||||
|
@ -355,7 +355,6 @@ class Importer:
|
||||||
isTourney=fpdb_simple.isTourney(hand[0])
|
isTourney=fpdb_simple.isTourney(hand[0])
|
||||||
if not isTourney:
|
if not isTourney:
|
||||||
fpdb_simple.filterAnteBlindFold(site,hand)
|
fpdb_simple.filterAnteBlindFold(site,hand)
|
||||||
hand=fpdb_simple.filterCrap(site, hand, isTourney)
|
|
||||||
self.hand=hand
|
self.hand=hand
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -65,6 +65,8 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
||||||
tourneyTypeId=fpdb_simple.recogniseTourneyTypeId(cursor, siteID, buyin, fee, knockout, rebuyOrAddon)
|
tourneyTypeId=fpdb_simple.recogniseTourneyTypeId(cursor, siteID, buyin, fee, knockout, rebuyOrAddon)
|
||||||
fpdb_simple.isAlreadyInDB(cursor, gametypeID, siteHandNo)
|
fpdb_simple.isAlreadyInDB(cursor, gametypeID, siteHandNo)
|
||||||
|
|
||||||
|
hand=fpdb_simple.filterCrap(site, hand, isTourney)
|
||||||
|
|
||||||
#part 2: classify lines by type (e.g. cards, action, win, sectionchange) and street
|
#part 2: classify lines by type (e.g. cards, action, win, sectionchange) and street
|
||||||
fpdb_simple.classifyLines(hand, category, lineTypes, lineStreets)
|
fpdb_simple.classifyLines(hand, category, lineTypes, lineStreets)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user