File tree Expand file tree Collapse file tree 5 files changed +20
-26
lines changed
Expand file tree Collapse file tree 5 files changed +20
-26
lines changed Original file line number Diff line number Diff line change @@ -177,18 +177,18 @@ To translate a search query on the command line, run
177177 Arguments
178178---------
179179
180- - ``--from `` (required):
181- The source query format.
180+ - ``--from `` (required):
181+ The source query format.
182182 Example: ``colrev_web_of_science ``
183183
184- - ``--input `` (required):
184+ - ``--input `` (required):
185185 Path to the input file containing the original query.
186186
187- - ``--to `` (required):
188- The target query format.
187+ - ``--to `` (required):
188+ The target query format.
189189 Example: ``colrev_pubmed ``
190190
191- - ``--output `` (required):
191+ - ``--output `` (required):
192192 Path to the file where the converted query will be written.
193193
194194
Original file line number Diff line number Diff line change @@ -39,8 +39,8 @@ dev = [
3939]
4040
4141[project .scripts ]
42- search-query-translate = " search_query.cli:main "
43- search-query-lint = " search_query.linter:main "
42+ search-query-translate = " search_query.cli:translate "
43+ search-query-lint = " search_query.linter:lint "
4444
4545[tool .pylint .MAIN ]
4646extension-pkg-whitelist = " lxml.etree"
Original file line number Diff line number Diff line change 2020
2121# Instead of adding elements to __all__,
2222# prefixing methods/variables with "__" is preferred.
23- # Imports like "from x import *" are discouraged.
23+ # Imports like "from x import *" are discouraged.
Original file line number Diff line number Diff line change 22"""CLI for search-query."""
33import argparse
44from pathlib import Path
5+
6+ import search_query .linter
57import search_query .parser
6- from search_query import SearchFile
78from search_query import load_search_file
89
910
10- def main ():
11+ def translate () -> None :
12+ """Main entrypoint for the query translation CLI"""
1113 parser = argparse .ArgumentParser (
1214 description = "Convert search queries between formats"
1315 )
@@ -47,17 +49,18 @@ def main():
4749 print (f"Convert from { args .source } to { args .target } " )
4850
4951 if Path (args .input_file ).suffix == ".json" :
50-
5152 search_file = load_search_file (args .input_file )
52- query = search_query .parser .parse (search_file .search_string , syntax = args .source , search_field_general = "" )
53+ query = search_query .parser .parse (
54+ search_file .search_string , syntax = args .source , search_field_general = ""
55+ )
5356 converted_query = query .to_string (syntax = args .target )
5457 search_file .search_string = converted_query
5558 search_file .save ()
5659
5760 else :
58- raise NotImplemented
59-
61+ raise NotImplementedError
6062
6163
62- if __name__ == "__main__" :
63- main ()
64+ def lint () -> None :
65+ """Main entrypoint for the query linter hook"""
66+ raise SystemExit (search_query .linter .pre_commit_hook ())
Original file line number Diff line number Diff line change @@ -64,12 +64,3 @@ def pre_commit_hook() -> int:
6464 return ExitCodes .FAIL
6565
6666 return ExitCodes .SUCCESS
67-
68-
69- def main () -> None :
70- """Main entrypoint for the query linter hook"""
71- raise SystemExit (pre_commit_hook ())
72-
73-
74- if __name__ == "__main__" :
75- main ()
You can’t perform that action at this time.
0 commit comments