Использование::
- ml-search.py [-i/-I] [-t/-s/-f] books [-t title] [-s series] [-a archive] [-f file] [-d] [--surname name] [--name name] [--misc-name name] [--fullname name] [-e ext] [-l lang]
+ ml-search.py [-i/-I] [-t/-s/-f] books [-t title] [-s series] [-a archive] [-f file] [-d] [--surname name] [--name name] [--misc-name name] [--fullname name] [--gname name] [--gtitle title] [-e ext] [-l lang]
Искать и печатать список книг по заголовку, серии, архиву, имени файла.
--misc-name misc. name Искать по доп. имени автора
--fullname name Искать по полному имени автора
-e, --ext ext Искать по расширению имени файла
+ --gname name Искать по названию жанра
+ --gtitle title Искать по заголовку жанра
-l, --lang lang Искать по языку
По умолчанию программы выводит список заголовков найденных книг. При
Usage::
- ml-search.py [-i/-I] [-t/-s/-f] books [-t title] [-s series] [-a archive] [-f file] [-d] [--surname name] [--name name] [--misc-name name] [--fullname name] [-e ext] [-l lang]
+ ml-search.py [-i/-I] [-t/-s/-f] books [-t title] [-s series] [-a archive] [-f file] [-d] [--surname name] [--name name] [--misc-name name] [--fullname name] [-e ext] [--gname name] [--gtitle title] [-l lang]
Search and print a list of books by title, series, archive or file name.
--misc-name misc. name Search by author's misc. name
--fullname name Search by author's full name
-e, --ext ext Search by file extension
+ --gname name Search by genre's name
+ --gtitle title Search by genre's title
-l, --lang lang Search by language
By default the program prints only titles of the found book. With one
from sqlobject.sqlbuilder import CONCAT
from m_lib.defenc import default_encoding
-from m_librarian.db import Author, Book, Extension, Language, open_db
+from m_librarian.db import Author, Book, Extension, Genre, Language, open_db
from m_librarian.search import mk_search_conditions, \
search_authors, search_books, \
search_extensions, search_genres, search_languages
if case_sensitive is None:
test_values = values.copy()
test_values.update(_get_values(args, 'surname', 'name', 'misc_name',
- 'fullname', 'ext', 'lang'))
+ 'fullname', 'ext', 'gname', 'gtitle',
+ 'lang'))
case_sensitive = _guess_case_sensitivity(test_values)
avalues = _get_values(args, 'surname', 'name', 'misc_name', 'fullname')
if avalues:
Extension, search_type, case_sensitive,
{'name': args.ext})
join_expressions.extend(conditions)
+ gvalues = {}
+ for column in 'name', 'title':
+ value = getattr(args, 'g' + column)
+ if value:
+ gvalues[column] = unicode(value, default_encoding)
+ if gvalues:
+ join_expressions.append(Book.j.genres)
+ conditions = mk_search_conditions(
+ Genre, search_type, case_sensitive, gvalues)
+ join_expressions.extend(conditions)
if args.lang:
join_expressions.append(Book.j.language)
conditions = mk_search_conditions(
parser.add_argument('--misc-name', help='search by author\'s misc. name')
parser.add_argument('--fullname', help='search by author\'s full name')
parser.add_argument('-e', '--ext', help='search by file extension')
+ parser.add_argument('--gname', help='search by genre\'s name')
+ parser.add_argument('--gtitle', help='search by genre\'s title')
parser.add_argument('-l', '--lang', help='search by language')
parser.set_defaults(func=_search_books)