]> git.phdru.name Git - m_librarian.git/blobdiff - scripts/ml-search.py
Style: Re-group and reorder imports
[m_librarian.git] / scripts / ml-search.py
index 7cc32e187d9b913d46010e0b06b9cc275c4bb383..7e6c9da3b793c02df82ea5d8570635258427a31a 100755 (executable)
@@ -2,12 +2,9 @@
 
 from __future__ import print_function
 import argparse
-try:
-    from configparser import NoSectionError, NoOptionError
-except ImportError:  # Python 2
-    from ConfigParser import NoSectionError, NoOptionError
 import os
 import sys
+
 from sqlobject.sqlbuilder import CONCAT
 
 from m_lib.defenc import default_encoding
@@ -157,7 +154,7 @@ def _search_books(case_sensitive, search_type, args):
             Language, search_type, case_sensitive, lvalues)
         join_expressions.extend(conditions)
     books = search_books(search_type, case_sensitive, values, join_expressions,
-                         orderBy=('series', 'ser_no', 'title'),
+                         orderBy=('series', 'ser_no', 'title', '-date'),
                          use_filters=args.filters)
     if args.count:
         print_count(books.count())
@@ -207,10 +204,7 @@ def _search_books(case_sensitive, search_type, args):
         if args.get or args.get_many:
             download_to = args.download_to
             if download_to is None:
-                try:
-                    download_to = get_config().get('download', 'path')
-                except (NoSectionError, NoOptionError):
-                    download_to = os.path.curdir
+                download_to = get_config().getpath('download', 'path')
             download(book, download_to, args.path, args.format)
         count += 1
     print_count(count)
@@ -384,7 +378,7 @@ if __name__ == '__main__':
 
     if int(args.start) + int(args.substring) + int(args.full) > 1:
         sys.stderr.write(
-            "Cannot search case sensitive and case insensitive "
+            "Cannot search from start, substring and full "
             "at the same time\n")
         main_parser.print_help()
         sys.exit(1)