From: Oleg Broytman Date: Mon, 30 May 2016 21:18:49 +0000 (+0300) Subject: Print count after the list X-Git-Tag: 0.0.10~3 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=5d81aa080a9184466ee950518a192bf8234c8c11;p=m_librarian.git Print count after the list --- diff --git a/ChangeLog b/ChangeLog index 3b0d6cf..2e8040a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ Version 0.0.10 (2016-05-??) + Print count after the list + Rename -d/--details options to -v/--verbose Version 0.0.9 (2016-05-30) diff --git a/m_librarian/translations/ru_RU.mo b/m_librarian/translations/ru_RU.mo index 26de52c..ce61803 100644 Binary files a/m_librarian/translations/ru_RU.mo and b/m_librarian/translations/ru_RU.mo differ diff --git a/m_librarian/translations/ru_RU.po b/m_librarian/translations/ru_RU.po index 6c56700..41e94f3 100644 --- a/m_librarian/translations/ru_RU.po +++ b/m_librarian/translations/ru_RU.po @@ -29,11 +29,14 @@ msgstr "Удалена" msgid "Extension" msgstr "Расширение" +msgid "False" +msgstr "Нет" + msgid "File" msgstr "Файл" -msgid "False" -msgstr "Нет" +msgid "Found" +msgstr "Найдено" msgid "Genre(s)" msgstr "Жанр(ы)" diff --git a/scripts/ml-search.py b/scripts/ml-search.py index 75a0114..d907481 100755 --- a/scripts/ml-search.py +++ b/scripts/ml-search.py @@ -30,6 +30,10 @@ def _guess_case_sensitivity(values): 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( @@ -51,7 +55,7 @@ def _search_authors(case_sensitive, search_type, args): 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)) @@ -62,6 +66,7 @@ def _search_authors(case_sensitive, search_type, args): if args.verbose >= 1: print "(id=%d)" % author.id, print + print_count(authors) def _search_books(case_sensitive, search_type, args): @@ -129,7 +134,7 @@ 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), @@ -167,6 +172,7 @@ def _search_books(case_sensitive, search_type, args): 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): @@ -178,7 +184,7 @@ 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), \ @@ -186,6 +192,7 @@ def _search_extensions(case_sensitive, search_type, args): if args.verbose >= 1: print "(id=%d)" % ext.id, print + print_count(extensions) def _search_genres(case_sensitive, search_type, args): @@ -194,7 +201,7 @@ 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)) @@ -204,6 +211,7 @@ def _search_genres(case_sensitive, search_type, args): if args.verbose >= 1: print "(id=%d)" % genre.id, print + print_count(genres) def _search_languages(case_sensitive, search_type, args): @@ -212,13 +220,18 @@ 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__':