Использование::
- ml-search.py [-i/-I] [-t/-s/-f] books [-t title] [-s series] [-a archive] [-f file] [-d] [-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] [-l lang]
Искать и печатать список книг по заголовку, серии, архиву, имени файла.
-d, --details Выводить больше информации о найденных книгах;
повторите эту опцию несколько раз, чтобы
получить ещё больше деталей
+ --surname surname Искать по фамилии автора
+ --name name Искать по имени автора
+ --misc-name misc. name Искать по доп. имени автора
+ --fullname name Искать по полному имени автора
-e, --ext ext Искать по расширению имени файла
-l, --lang lang Искать по языку
Usage::
- ml-search.py [-i/-I] [-t/-s/-f] books [-t title] [-s series] [-a archive] [-f file] [-d] [-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] [-l lang]
Search and print a list of books by title, series, archive or file name.
-f, --file file Search by file name (without extension)
-d, --details Output more details about books;
repeat for even more details
+ --surname surname Search by author's surname
+ --name name Search by author's 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
-l, --lang lang Search by language
values = _get_values(args, 'title', 'series', 'archive', 'file')
if case_sensitive is None:
test_values = values.copy()
- test_values.update(_get_values(args, 'ext', 'lang'))
+ test_values.update(_get_values(args, 'surname', 'name', 'misc_name',
+ 'fullname', 'ext', 'lang'))
case_sensitive = _guess_case_sensitivity(test_values)
+ avalues = _get_values(args, 'surname', 'name', 'misc_name', 'fullname')
+ if avalues:
+ if (args.surname or args.name or args.misc_name) and args.fullname:
+ sys.stderr.write(
+ "Cannot search by names and full name at the same time\n")
+ main_parser.print_help()
+ sys.exit(1)
+ expressions = []
+ join_expressions.append(Book.j.authors)
+ value = args.fullname
+ if value:
+ expressions.append((
+ CONCAT(Author.q.surname, ' ', Author.q.name, ' ',
+ Author.q.misc_name),
+ unicode(value, default_encoding)
+ ))
+ conditions = mk_search_conditions(
+ Author, search_type, case_sensitive, avalues, expressions)
+ join_expressions.extend(conditions)
if args.ext:
join_expressions.append(Book.j.extension)
conditions = mk_search_conditions(
parser.add_argument('-d', '--details', action='count',
help='output more details about books; '
'repeat for even more details')
+ parser.add_argument('--surname', help='search by author\'s surname')
+ parser.add_argument('--name', help='search by author\'s name')
+ 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('-l', '--lang', help='search by language')
parser.set_defaults(func=_search_books)