Allow calibredb list to output only book ids

Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
Kovid Goyal 2013-07-27 15:19:56 +05:30
commit 694dfe5dc2
2 changed files with 13 additions and 10 deletions

View File

@ -921,7 +921,7 @@ class ResultCache(SearchQueryParser): # {{{
def remove(self, id): def remove(self, id):
try: try:
self._uuid_map.pop(self._data[id][self._uuid_column_index], None) self._uuid_map.pop(self._data[id][self._uuid_column_index], None)
except IndexError: except (IndexError, TypeError):
pass # id is out of bounds -- no uuid in the map to remove pass # id is out of bounds -- no uuid in the map to remove
try: try:
self._data[id] = None self._data[id] = None

View File

@ -199,6 +199,7 @@ def command_list(args, dbpath):
afields.add('*'+f) afields.add('*'+f)
if data['datatype'] == 'series': if data['datatype'] == 'series':
afields.add('*'+f+'_index') afields.add('*'+f+'_index')
if opts.fields.strip():
fields = [str(f.strip().lower()) for f in opts.fields.split(',')] fields = [str(f.strip().lower()) for f in opts.fields.split(',')]
if 'all' in fields: if 'all' in fields:
fields = sorted(list(afields)) fields = sorted(list(afields))
@ -208,6 +209,8 @@ def command_list(args, dbpath):
prints(_('Invalid fields. Available fields:'), prints(_('Invalid fields. Available fields:'),
','.join(sorted(afields)), file=sys.stderr) ','.join(sorted(afields)), file=sys.stderr)
return 1 return 1
else:
fields = []
if not opts.sort_by in afields and opts.sort_by is not None: if not opts.sort_by in afields and opts.sort_by is not None:
parser.print_help() parser.print_help()