Использование::
- ml-search.py books [-t title] [-s series] [-a archive] [-f file] [-p path] [--get] [--id id] [--surname name] [--name name] [--misc-name name] [--fullname name] [--aid aid] [-e ext] [--eid eid] [--gname name] [--gtitle title] [--gid gid] [-l lang] [--lid lid]
+ ml-search.py books [-t title] [-s series] [-a archive] [-f file] [-p path] [--get] [--get-many N] [--id id] [--surname name] [--name name] [--misc-name name] [--fullname name] [--aid aid] [-e ext] [--eid eid] [--gname name] [--gtitle title] [--gid gid] [-l lang] [--lid lid]
Искать и печатать список книг по заголовку, серии, архиву, имени файла.
-f, --file файл Искать по имени файла (без расширения)
-p, --path path Путь к директории с архивами библиотеки
--get Загрузить ровно один файл
+ --get-many N Загрузить не больше указанного числа файлов
--id id Искать по id книги
--surname surname Искать по фамилии автора
--name name Искать по имени автора
в конец с точкой в качестве разделителя. Т.о. формат `%f` эквивалентен
формату `%f.%e`.
+Опция `--get-many N` позволяет загрузить указанное число книг (не больше
+чем N, где N — целое число.) Опции `--get-many N` и `--get` взаимно
+исключают друг друга и не должны использоваться одновременно.
+
Поиск расширений
^^^^^^^^^^^^^^^^
Usage::
- ml-search.py books [-t title] [-s series] [-a archive] [-f file] [-p path] [--get] [--id id] [--surname name] [--name name] [--misc-name name] [--fullname name] [--aid aid] [-e ext] [--eid eid] [--gname name] [--gtitle title] [--gid gid] [-l lang] [--lid lid]
+ ml-search.py books [-t title] [-s series] [-a archive] [-f file] [-p path] [--get] [--get-many N] [--id id] [--surname name] [--name name] [--misc-name name] [--fullname name] [--aid aid] [-e ext] [--eid eid] [--gname name] [--gtitle title] [--gid gid] [-l lang] [--lid lid]
Search and print a list of books by title, series, archive or file name.
-p, --path path Path to the directory with the library
archives
--get Download exactly one book
+ --get-many N Download at most this many books
--id id Search by database id
--surname surname Search by author’s surname
--name name Search by author’s name
unconditionally with a dot. That is, format `%f` is equivalent to
`%f.%e`.
+Option `--get-many N` allows to download many books (at most N, where N
+is an integer). Options `--get-many N` and `--get` are, of course,
+mutually incompatible.
+
Extension search
^^^^^^^^^^^^^^^^
def _search_books(case_sensitive, search_type, args):
+ if args.get and args.get_many:
+ sys.stderr.write(
+ "Cannot get one book and many books at the same time\n")
+ main_parser.print_help()
+ sys.exit(1)
join_expressions = []
values = _get_values(args, 'title', 'series', 'archive', 'file', 'id')
if case_sensitive is None:
if args.count:
print_count(books.count())
return
- if args.get:
+ if args.get_many:
+ books = books[:args.get_many]
+ elif args.get:
count = books.count()
if count != 1:
sys.stderr.write("There must be exactly 1 book for --get; "
"(found %d).\n" % count)
+ sys.stderr.write("Use --get-many N to download more than one "
+ "book.\n")
sys.exit(1)
- book = books[0]
- download(book, args.path)
- return
count = 0
for book in books:
print book.title.encode(default_encoding),
book.size, _("bytes").encode(default_encoding)
print " ", _("Deleted").encode(default_encoding), ":", \
_(str(book.deleted)).encode(default_encoding)
+ if args.get or args.get_many:
+ download(book, args.path)
count += 1
print_count(count)
parser.add_argument('-p', '--path', help='path to the library archives')
parser.add_argument('--get', action='store_true',
help='download exactly one book')
+ parser.add_argument('--get-many', type=int,
+ help='download at most this many books')
parser.add_argument('--id', type=int, help='search by database id')
parser.add_argument('--surname', help='search by author\'s surname')
parser.add_argument('--name', help='search by author\'s name')