]> git.phdru.name Git - m_librarian.git/commitdiff
Print count after the list
authorOleg Broytman <phd@phdru.name>
Mon, 30 May 2016 21:18:49 +0000 (00:18 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 30 May 2016 21:22:32 +0000 (00:22 +0300)
ChangeLog
m_librarian/translations/ru_RU.mo
m_librarian/translations/ru_RU.po
scripts/ml-search.py

index 3b0d6cf3d1d82b9772ee5007cee8349367c97008..2e8040a588067b5a6086a0a7578f019c08f30e72 100644 (file)
--- 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)
index 26de52cfe407f2bc5ed213b2a02586f4f6685e4a..ce61803f80a6cf3ee5178e2a825ba03b8bfc756e 100644 (file)
Binary files a/m_librarian/translations/ru_RU.mo and b/m_librarian/translations/ru_RU.mo differ
index 6c56700fa243496c18e4be0a9b486612f777a208..41e94f36d3bdabf45876c70c19cce4b6a5850d2f 100644 (file)
@@ -29,11 +29,14 @@ msgstr "Удалена"
 msgid "Extension"
 msgstr "Расширение"
 
+msgid "False"
+msgstr "Нет"
+
 msgid "File"
 msgstr "Файл"
 
-msgid "False"
-msgstr "п²п╣я┌"
+msgid "Found"
+msgstr "п²п╟п╧п╢п╣п╫п╬"
 
 msgid "Genre(s)"
 msgstr "Жанр(ы)"
index 75a011435c2bb591da53f7234aa7e6ec407e85f0..d9074813164515269704c398e750886e3a7923ae 100755 (executable)
@@ -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__':