def command_fix(options, collection_name): log_info('Fixing collection {}'.format(collection_name)) configuration = common.parse_File_Config(options) collection = perform_scanner(configuration, collection_name) for set in collection.sets: if set.status == common.ROMset.SET_STATUS_BADNAME: common.fix_ROM_set(set) # Rescan collection and store results in chache. command_scan(options, collection_name)
def command_deleteUnknown(options, collection_name): log_info('Deleting Unknown SETs in collection {}'.format(collection_name)) configuration = common.parse_File_Config(options) collection = perform_scanner(configuration, collection_name) for set in collection.sets: if set.status == common.ROMset.SET_STATUS_UNKNOWN: print('Deleting {}'.format(set.basename)) os.remove(set.filename) # Rescan collection and store results in chache. command_scan(options, collection_name)
def command_scanall(options): log_info('Scanning all collections') configuration = common.parse_File_Config(options) # Scan collection by collection. stats_list = [] for collection_name in configuration.collections: collection = perform_scanner(configuration, collection_name) # Save scanner results for later. scan_FN = options.data_dir_FN.pjoin(collection.name + '_scan.bin') print('Saving scanner results in "{}"'.format(scan_FN.getPath())) f = open(scan_FN.getPath(), 'wb') pickle.dump(collection, f) f.close()
def command_statusall(options): log_info('View all collections scan results') configuration = common.parse_File_Config(options) stats_list = [] for collection_name in configuration.collections: # Load collection scanner data. scan_FN = options.data_dir_FN.pjoin(collection_name + '_scan.bin') if not scan_FN.exists(): print('Not found {}'.format(scan_FN.getPath())) print('Exiting') sys.exit(1) print('Loading scanner results in "{}"'.format(scan_FN.getPath())) f = open(scan_FN.getPath(), 'rb') collection = pickle.load(f) f.close() stats = common.get_collection_statistics(collection) stats_list.append(stats) # Print results. table_str = [ ['left', 'left', 'left', 'left', 'left', 'left', 'left', 'left'], [ 'Collection', 'DAT SETs', 'Total ROMs', 'Have ROMs', 'BadName ROMs', 'Miss ROMs', 'Unknown ROMs', 'Error files' ], ] for stats in stats_list: table_str.append([ str(stats['name']), str(stats['total_DAT']), str(stats['total']), str(stats['have']), str(stats['badname']), str(stats['missing']), str(stats['unknown']), str(stats['error']), ]) table_text = common.text_render_table(table_str) print('') for line in table_text: print(line)
def command_scan(options, collection_name): log_info('Scanning collection') configuration = common.parse_File_Config(options) collection = perform_scanner(configuration, collection_name) # Save scanner results for later. scan_FN = options.data_dir_FN.pjoin(collection.name + '_scan.bin') print('Saving scanner results in "{}"'.format(scan_FN.getPath())) f = open(scan_FN.getPath(), 'wb') pickle.dump(collection, f) f.close() # Print scanner summary. stats = common.get_collection_statistics(collection) print('\n=== Scanner summary for collection "{}" ==='.format( collection_name)) print('Total SETs in DAT {:5,}'.format(stats['total_DAT'])) print('Total SETs {:5,}'.format(stats['total'])) print('Have SETs {:5,}'.format(stats['have'])) print('Badname SETs {:5,}'.format(stats['badname'])) print('Miss SETs {:5,}'.format(stats['missing'])) print('Unknown SETs {:5,}'.format(stats['unknown'])) print('Error SETs {:5,}'.format(stats['error']))
def command_listcollections(options): log_info('Listing ROM Collections in the configuration file') # Read the configuration file. configuration = common.parse_File_Config(options) # pprint.pprint(configuration.collections) # Print the ROM Collections in the configuration file. # Use the table printing engine from AML/AEL. table_str = [ ['left', 'left', 'left'], ['Name', 'DAT file', 'ROM dir'], ] for key in configuration.collections: collection = configuration.collections[key] table_str.append( [collection['name'], collection['DAT'], collection['ROM_dir']]) # Print table table_text = common.text_render_table(table_str) print('') for line in table_text: print(line)