This commit is contained in:
Kovid Goyal 2008-06-21 15:45:47 -07:00
parent 39d6c724d3
commit aab8744748

View File

@ -100,14 +100,14 @@ List the books available in the calibre database.
if not set(fields).issubset(FIELDS):
parser.print_help()
print
print _('Invalid fields. Available fields:'), ','.join(FIELDS)
print >>sys.stderr, _('Invalid fields. Available fields:'), ','.join(FIELDS)
return 1
db = get_db(dbpath, opts)
if not opts.sort_by in FIELDS:
parser.print_help()
print
print _('Invalid sort field. Available fields:'), ','.join(FIELDS)
print >>sys.stderr, _('Invalid sort field. Available fields:'), ','.join(FIELDS)
return 1
do_list(db, fields, opts.sort_by, opts.ascending, opts.search)
@ -121,6 +121,7 @@ class DevNull(object):
NULL = DevNull()
def do_add(db, paths, one_book_per_directory, recurse, add_duplicates):
orig = sys.stdout
sys.stdout = NULL
try:
files, dirs = [], []
@ -169,26 +170,26 @@ def do_add(db, paths, one_book_per_directory, recurse, add_duplicates):
for mi, formats in dir_dups:
db.import_book(mi, formats)
else:
print _('The following books were not added as they already exist in the database (see --duplicates option):')
print >>sys.stderr, _('The following books were not added as they already exist in the database (see --duplicates option):')
for mi, formats in dir_dups:
title = mi.title
if isinstance(title, unicode):
title = title.encode(preferred_encoding)
print '\t', title + ':'
print >>sys.stderr, '\t', title + ':'
for path in formats:
print '\t\t ', path
print >>sys.stderr, '\t\t ', path
if file_duplicates:
for path, mi in zip(file_duplicates[0], file_duplicates[2]):
title = mi.title
if isinstance(title, unicode):
title = title.encode(preferred_encoding)
print '\t', title+':'
print '\t\t ', path
print >>sys.stderr, '\t', title+':'
print >>sys.stderr, '\t\t ', path
if send_message is not None:
send_message('refreshdb:', 'calibre GUI')
finally:
sys.stdout = sys.__stdout__
sys.stdout = orig
@ -211,7 +212,7 @@ the directory related options below.
if len(args) < 2:
parser.print_help()
print
print _('You must specify at least one file to add')
print >>sys.stderr, _('You must specify at least one file to add')
return 1
do_add(get_db(dbpath, opts), args[1:], opts.one_book_per_directory, opts.recurse, opts.duplicates)
return 0
@ -241,7 +242,7 @@ list of id numbers (you can get id numbers by using the list command). For examp
if len(args) < 2:
parser.print_help()
print
print _('You must specify at least one book to remove')
print >>sys.stderr, _('You must specify at least one book to remove')
return 1
ids = []
@ -272,7 +273,7 @@ by id. You can get id by using the list command. If the format already exists, i
if len(args) < 3:
parser.print_help()
print
print _('You must specify an id and an ebook file')
print >>sys.stderr, _('You must specify an id and an ebook file')
return 1
id, file, fmt = int(args[1]), open(args[2], 'rb'), os.path.splitext(args[2])[-1]
@ -298,7 +299,7 @@ do nothing.
if len(args) < 3:
parser.print_help()
print
print _('You must specify an id and a format')
print >>sys.stderr, _('You must specify an id and a format')
return 1
id, fmt = int(args[1]), args[2].upper()
@ -329,7 +330,7 @@ id is an id number from the list command.
if len(args) < 2:
parser.print_help()
print
print _('You must specify an id')
print >>sys.stderr, _('You must specify an id')
return 1
id = int(args[1])
do_show_metadata(get_db(dbpath, opts), id, opts.as_opf)
@ -356,7 +357,7 @@ show_metadata command.
if len(args) < 3:
parser.print_help()
print
print _('You must specify an id and a metadata file')
print >>sys.stderr, _('You must specify an id and a metadata file')
return 1
id, opf = int(args[1]), open(args[2], 'rb')
do_set_metadata(get_db(dbpath, opts), id, opf)