Использование::
- ml-search.py [-i/-I] [-t/-s/-f] books [-t title] [-s series] [-a archive] [-f file] [-d] [-e ext]
+ ml-search.py [-i/-I] [-t/-s/-f] books [-t title] [-s series] [-a archive] [-f file] [-d] [-e ext] [-l lang]
Искать и печатать список книг по заголовку, серии, архиву, имени файла.
повторите эту опцию несколько раз, чтобы
получить ещё больше деталей
-e, --ext ext Искать по расширению имени файла
+ -l, --lang lang Искать по языку
По умолчанию программы выводит список заголовков найденных книг. При
использовании опции `-d` также выводится список авторов и жанров, а
Usage::
- ml-search.py [-i/-I] [-t/-s/-f] books [-t title] [-s series] [-a archive] [-f file] [-d] [-e ext]
+ ml-search.py [-i/-I] [-t/-s/-f] books [-t title] [-s series] [-a archive] [-f file] [-d] [-e ext] [-l lang]
Search and print a list of books by title, series, archive or file name.
-d, --details Output more details about books;
repeat for even more details
-e, --ext ext Search by file extension
+ -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
from sqlobject.sqlbuilder import CONCAT
from m_lib.defenc import default_encoding
-from m_librarian.db import Author, Book, Extension, open_db
+from m_librarian.db import Author, Book, Extension, Language, open_db
from m_librarian.search import mk_search_conditions, \
search_authors, search_books, \
search_extensions, search_genres, search_languages
values[column] = unicode(value, default_encoding)
if case_sensitive is None:
test_values = values.copy()
- for column in 'ext', :
+ for column in 'ext', 'lang':
value = getattr(args, column)
if value:
test_values[column] = unicode(value, default_encoding)
Extension, search_type, case_sensitive,
{'name': args.ext})
join_expressions.extend(conditions)
+ if args.lang:
+ join_expressions.append(Book.j.language)
+ conditions = mk_search_conditions(
+ Language, search_type, case_sensitive,
+ {'name': args.lang})
+ join_expressions.extend(conditions)
for book in search_books(search_type, case_sensitive, values,
join_expressions,
orderBy=('series', 'ser_no', 'title')):
help='output more details about books; '
'repeat for even more details')
parser.add_argument('-e', '--ext', help='search by file extension')
+ parser.add_argument('-l', '--lang', help='search by language')
parser.set_defaults(func=_search_books)
parser = subparsers.add_parser('ext', help='Search extensions')