return False
+def print_count(query):
+ print _("Found").encode(default_encoding), ":", query.count()
+
+
def _search_authors(case_sensitive, search_type, args):
if (args.surname or args.name or args.misc_name) and args.fullname:
sys.stderr.write(
authors = search_authors(search_type, case_sensitive, values, expressions,
orderBy=('surname', 'name', 'misc_name'))
if args.count:
- print authors.count()
+ print_count(authors)
return
for author in authors:
names = filter(None, (author.surname, author.name, author.misc_name))
if args.verbose >= 1:
print "(id=%d)" % author.id,
print
+ print_count(authors)
def _search_books(case_sensitive, search_type, args):
books = search_books(search_type, case_sensitive, values, join_expressions,
orderBy=('series', 'ser_no', 'title'))
if args.count:
- print books.count()
+ print_count(books)
return
for book in books:
print book.title.encode(default_encoding),
book.size, _("bytes").encode(default_encoding)
print " ", _("Deleted").encode(default_encoding), ":", \
_(str(book.deleted)).encode(default_encoding)
+ print_count(books)
def _search_extensions(case_sensitive, search_type, args):
extensions = search_extensions(search_type, case_sensitive, values,
orderBy='name')
if args.count:
- print extensions.count()
+ print_count(extensions)
return
for ext in extensions:
print ext.name.encode(default_encoding), \
if args.verbose >= 1:
print "(id=%d)" % ext.id,
print
+ print_count(extensions)
def _search_genres(case_sensitive, search_type, args):
case_sensitive = _guess_case_sensitivity(values)
genres = search_genres(search_type, case_sensitive, values, orderBy='name')
if args.count:
- print genres.count()
+ print_count(genres)
return
for genre in genres:
names = filter(None, (genre.name, genre.title))
if args.verbose >= 1:
print "(id=%d)" % genre.id,
print
+ print_count(genres)
def _search_languages(case_sensitive, search_type, args):
case_sensitive = _guess_case_sensitivity(values)
else:
values = {}
- for lang in search_languages(search_type, case_sensitive, values,
- orderBy='name'):
+ languages = search_languages(search_type, case_sensitive, values,
+ orderBy='name')
+ if args.count:
+ print_count(languages)
+ return
+ for lang in languages:
print lang.name.encode(default_encoding), \
(u"(%s: %d)" % (_('books'), lang.count)).encode(default_encoding),
if args.verbose >= 1:
print "(id=%d)" % lang.id,
print
+ print_count(languages)
if __name__ == '__main__':