From: Oleg Broytman Date: Sat, 14 May 2016 15:11:38 +0000 (+0300) Subject: Allow to list all extensions and genres X-Git-Tag: 0.0.5~1 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=07794a8efe6512dd65b98c692d35a1a41ed5683e;p=m_librarian.git Allow to list all extensions and genres --- diff --git a/docs-ru/command_line.rst b/docs-ru/command_line.rst index b219022..9a383c4 100644 --- a/docs-ru/command_line.rst +++ b/docs-ru/command_line.rst @@ -67,10 +67,10 @@ ml-search.py Использование:: - ml-search.py [-i] [-I] [-t ...] author [-s surname] [-n name] [-m misc-name] + ml-search.py [-i] [-I] [-t ...] author [-s surname] [-n name] [-m misc-name] [fullname] -Искать и печатать список авторов по фамилии, имени и доп. имени (обычно -отчеству). +Искать и печатать список авторов по фамилии, имени, доп. имени (обычно +отчеству) или полному имени. Опции:: @@ -98,7 +98,7 @@ ml-search.py Использование:: - ml-search.py [-i] [-I] [-t ...] ext name + ml-search.py [-i] [-I] [-t ...] ext [name] Искать и печатать список расширений имён файлов по имени. @@ -121,7 +121,7 @@ ml-search.py Использование:: - ml-search.py [-i] [-I] [-t ...] lang name + ml-search.py [-i] [-I] [-t ...] lang [name] Искать и печатать список языков по имени. diff --git a/docs/command_line.rst b/docs/command_line.rst index ca386bd..4b30eb6 100644 --- a/docs/command_line.rst +++ b/docs/command_line.rst @@ -66,9 +66,9 @@ Author search Usage:: - ml-search.py [-i] [-I] [-t ...] author [-s surname] [-n name] [-m misc-name] + ml-search.py [-i] [-I] [-t ...] author [-s surname] [-n name] [-m misc-name] [fullname] -Search and print a list of authors by surname/name/misc name. +Search and print a list of authors by surname/name/misc name/full name. Options:: @@ -96,7 +96,7 @@ Extension search Usage:: - ml-search.py [-i] [-I] [-t ...] ext name + ml-search.py [-i] [-I] [-t ...] ext [name] Search and print a list of extensions by name. @@ -119,7 +119,7 @@ Language search Usage:: - ml-search.py [-i] [-I] [-t ...] lang name + ml-search.py [-i] [-I] [-t ...] lang [name] Search and print a list of languages by name. diff --git a/m_librarian/db.py b/m_librarian/db.py index 771fd57..7e5744f 100755 --- a/m_librarian/db.py +++ b/m_librarian/db.py @@ -76,7 +76,7 @@ class BookGenre(SQLObject): class Extension(SQLObject): - name = StringCol(notNull=True, unique=True) + name = UnicodeCol(notNull=True, unique=True) count = IntCol(notNull=True) count_idx = DatabaseIndex(count) @@ -93,7 +93,7 @@ class Genre(SQLObject): class Language(SQLObject): - name = StringCol(notNull=True, unique=True) + name = UnicodeCol(notNull=True, unique=True) count = IntCol(notNull=True) count_idx = DatabaseIndex(count) diff --git a/scripts/ml-search.py b/scripts/ml-search.py index e4ae011..2915f51 100755 --- a/scripts/ml-search.py +++ b/scripts/ml-search.py @@ -51,9 +51,12 @@ def _search_authors(case_sensitive, args): def _search_extensions(case_sensitive, args): - values = {'name': args.name} - if case_sensitive is None: - case_sensitive = _guess_case_sensitivity(values) + if args.name: + values = {'name': args.name} + if case_sensitive is None: + case_sensitive = _guess_case_sensitivity(values) + else: + values = {} for ext in search_extensions(args.search_type, case_sensitive, values): print ext.name.encode(default_encoding), \ (u"(%s: %d)" % (_('books'), ext.count)).encode(default_encoding) @@ -76,9 +79,12 @@ def _search_genres(case_sensitive, args): def _search_languages(case_sensitive, args): - values = {'name': args.name} - if case_sensitive is None: - case_sensitive = _guess_case_sensitivity(values) + if args.name: + values = {'name': args.name} + if case_sensitive is None: + case_sensitive = _guess_case_sensitivity(values) + else: + values = {} for lang in search_languages(args.search_type, case_sensitive, values): print lang.name.encode(default_encoding), \ (u"(%s: %d)" % (_('books'), lang.count)).encode(default_encoding) @@ -109,7 +115,7 @@ if __name__ == '__main__': parser.set_defaults(func=_search_authors) parser = subparsers.add_parser('ext', help='Search extensions') - parser.add_argument('name', help='search by name') + parser.add_argument('name', nargs='?', help='search by name') parser.set_defaults(func=_search_extensions) parser = subparsers.add_parser('genres', help='Search genres') @@ -118,7 +124,7 @@ if __name__ == '__main__': parser.set_defaults(func=_search_genres) parser = subparsers.add_parser('lang', help='Search languages') - parser.add_argument('name', help='search by name') + parser.add_argument('name', nargs='?', help='search by name') parser.set_defaults(func=_search_languages) args = main_parser.parse_args()