|
8 | 8 | from collections import defaultdict |
9 | 9 | from importlib import import_module |
10 | 10 | from difflib import get_close_matches |
| 11 | +from argparse import Namespace |
11 | 12 |
|
12 | 13 | from slugify import slugify |
13 | 14 |
|
14 | | -from .utils import DATA_TYPES, BUILTINS, HINT_MESSAGES, API_SEARCH_URL |
| 15 | +from .utils import DATA_TYPES, BUILTINS, HINT_MESSAGES, SEARCH_URL |
15 | 16 | from .utils import ( |
16 | 17 | SINGLE_QUOTE_CHAR, |
17 | 18 | DOUBLE_QUOTE_CHAR, |
|
20 | 21 | ) |
21 | 22 |
|
22 | 23 |
|
23 | | -def handle_error(error_info: dict, n_questions: int, dry_run: bool = False) -> str: |
| 24 | +def handle_error(error_info: dict, cmd_args: Namespace) -> str: |
24 | 25 | """Process the incoming error as needed and outputs three possible answer. |
25 | 26 | output: |
26 | 27 | query: an URL containing an stackoverflow query about the error. |
@@ -66,9 +67,9 @@ def handle_error(error_info: dict, n_questions: int, dry_run: bool = False) -> s |
66 | 67 | else: |
67 | 68 | query = url_for_error(error_message) # default query |
68 | 69 |
|
69 | | - query = set_pagesize(query, n_questions) if query else None |
| 70 | + query = set_pagesize(query, cmd_args.n_questions) if query else None |
70 | 71 |
|
71 | | - if dry_run: |
| 72 | + if cmd_args.dry_run: |
72 | 73 | print(query) |
73 | 74 | exit() |
74 | 75 |
|
@@ -270,7 +271,7 @@ def get_query_params(error_message: str): |
270 | 271 | def url_for_error(error_message: str) -> str: |
271 | 272 | """Build a valid search url.""" |
272 | 273 |
|
273 | | - return API_SEARCH_URL + get_query_params(error_message) |
| 274 | + return SEARCH_URL + get_query_params(error_message) |
274 | 275 |
|
275 | 276 |
|
276 | 277 | def get_quoted_words(error_message: str) -> List[str]: |
|
0 commit comments