From: Oleg Broytman Date: Sun, 29 May 2016 16:37:39 +0000 (+0300) Subject: Use option -d to output database id X-Git-Tag: 0.0.8~4 X-Git-Url: https://git.phdru.name/?p=m_librarian.git;a=commitdiff_plain;h=fc42dcaa2908ea3d5f7e1db5d4a777bbac9a05b4 Use option -d to output database id --- diff --git a/docs-ru/command_line.rst b/docs-ru/command_line.rst index f6ee8d8..a74b45b 100644 --- a/docs-ru/command_line.rst +++ b/docs-ru/command_line.rst @@ -97,6 +97,8 @@ ml-search.py Искать и печатать список авторов, чья фамилия начинается на "друг" и имя начинается на "в", без учёта регистра. +При использовании опции `-d` также выводится id из БД. + Поиск книг ^^^^^^^^^^ @@ -123,12 +125,12 @@ ml-search.py -l, --lang lang Искать по языку По умолчанию программы выводит список заголовков найденных книг. При -использовании опции `-d` также выводится список авторов и жанров, а -также серия, к которой принадлежит книга (если принадлежит) и порядковый -номер книги в этой серии. С двумя опциями `-d` (`-d -d` или просто -`-dd`) программа выводит дату файла и язык. С тремя `-d` выводятся имя -архива, имя файла, расширение и размер файла, и признак, была ли книга -помечена как удалённая. +использовании опции `-d` также выводится id из БД, список авторов и +жанров, а также серия, к которой принадлежит книга (если принадлежит) и +порядковый номер книги в этой серии. С двумя опциями `-d` (`-d -d` или +просто `-dd`) программа выводит дату файла и язык. С тремя `-d` +выводятся имя архива, имя файла, расширение и размер файла, и признак, +была ли книга помечена как удалённая. Поиск расширений @@ -140,6 +142,8 @@ ml-search.py Искать и печатать список расширений имён файлов по имени. +При использовании опции `-d` также выводится id из БД. + Поиск жанров ^^^^^^^^^^^^ @@ -155,6 +159,8 @@ ml-search.py -n, --name имя Искать по названию -t, --title заголовок Искать по заголовку +При использовании опции `-d` также выводится id из БД. + Поиск языков ^^^^^^^^^^^^ @@ -165,4 +171,6 @@ ml-search.py Искать и печатать список языков по имени. +При использовании опции `-d` также выводится id из БД. + .. vim: set tw=72 : diff --git a/docs/command_line.rst b/docs/command_line.rst index 3db7014..0fab06b 100644 --- a/docs/command_line.rst +++ b/docs/command_line.rst @@ -92,9 +92,11 @@ Example:: ml-search.py -i author -s duck -n mack -Search and print a list of authors whose surname starts with "duck", and +Search and print a list of authors whose surname starts with "duck" and name starts with "mack", case insensitive. +With one option `-d` it also prints database id. + Book search ^^^^^^^^^^^ @@ -121,12 +123,12 @@ Options:: -l, --lang lang Search by language By default the program prints only titles of the found book. With one -option `-d` it also prints the list of authors and genres, and also -series the book belongs to (if any) and the serial number of the book in -the series. With two options `-d` (`-d -d` or simply `-dd`) it also -prints the file date and language. With three `-d` it prints archive -name, file name, extension and size, and flag if the book is marked to -be deleted. +option `-d` it also prints database id, the list of authors and genres, +and also series the book belongs to (if any) and the serial number of +the book in the series. With two options `-d` (`-d -d` or simply `-dd`) +it also prints the file date and language. With three `-d` it prints +archive name, file name, extension and size, and flag if the book is +marked to be deleted. Extension search @@ -138,6 +140,8 @@ Usage:: Search and print a list of extensions by name. +With one option `-d` it also prints database id. + Genres search ^^^^^^^^^^^^^ @@ -153,6 +157,8 @@ Options:: -n, --name name Search by name -t, --title title Search by title +With one option `-d` it also prints database id. + Language search ^^^^^^^^^^^^^^^ @@ -163,4 +169,6 @@ Usage:: Search and print a list of languages by name. +With one option `-d` it also prints database id. + .. vim: set tw=72 : diff --git a/scripts/ml-search.py b/scripts/ml-search.py index 0bef3c7..e23e4a5 100755 --- a/scripts/ml-search.py +++ b/scripts/ml-search.py @@ -54,7 +54,11 @@ def _search_authors(case_sensitive, search_type, args): names = filter(None, (author.surname, author.name, author.misc_name)) fullname = u' '.join(names) print fullname.encode(default_encoding), \ - (u"(%s: %d)" % (_('books'), author.count)).encode(default_encoding) + (u"(%s: %d)" % (_('books'), author.count))\ + .encode(default_encoding), + if args.details >= 1: + print "(id=%d)" % author.id, + print def _search_books(case_sensitive, search_type, args): @@ -110,7 +114,10 @@ def _search_books(case_sensitive, search_type, args): for book in search_books(search_type, case_sensitive, values, join_expressions, orderBy=('series', 'ser_no', 'title')): - print book.title.encode(default_encoding) + print book.title.encode(default_encoding), + if args.details >= 1: + print "(id=%d)" % book.id, + print if args.details >= 1: print " ", _("Author(s)"), ":", for author in book.authors: @@ -150,7 +157,10 @@ def _search_extensions(case_sensitive, search_type, args): for ext in search_extensions(search_type, case_sensitive, values, orderBy='name'): print ext.name.encode(default_encoding), \ - (u"(%s: %d)" % (_('books'), ext.count)).encode(default_encoding) + (u"(%s: %d)" % (_('books'), ext.count)).encode(default_encoding), + if args.details >= 1: + print "(id=%d)" % ext.id, + print def _search_genres(case_sensitive, search_type, args): @@ -162,7 +172,10 @@ def _search_genres(case_sensitive, search_type, args): names = filter(None, (genre.name, genre.title)) fullname = u' '.join(names) print fullname.encode(default_encoding), \ - (u"(%s: %d)" % (_('books'), genre.count)).encode(default_encoding) + (u"(%s: %d)" % (_('books'), genre.count)).encode(default_encoding), + if args.details >= 1: + print "(id=%d)" % genre.id, + print def _search_languages(case_sensitive, search_type, args): @@ -175,7 +188,10 @@ def _search_languages(case_sensitive, search_type, args): for lang in search_languages(search_type, case_sensitive, values, orderBy='name'): print lang.name.encode(default_encoding), \ - (u"(%s: %d)" % (_('books'), lang.count)).encode(default_encoding) + (u"(%s: %d)" % (_('books'), lang.count)).encode(default_encoding), + if args.details >= 1: + print "(id=%d)" % lang.id, + print if __name__ == '__main__':