|
7 | 7 | from pathlib import Path |
8 | 8 | from typing import Any |
9 | 9 |
|
10 | | -from cli2gui.types import SEP, ParserType |
| 10 | +from cli2gui.models import SEP, ParserType |
11 | 11 |
|
12 | 12 |
|
13 | 13 | def processValue(key: str, value: str) -> tuple[str, Any]: |
@@ -44,44 +44,44 @@ def processValue(key: str, value: str) -> tuple[str, Any]: |
44 | 44 | def argparseFormat(values: dict[str, Any]) -> argparse.Namespace: |
45 | 45 | """Format args for argparse.""" |
46 | 46 | args = {} |
47 | | - for key in values: |
48 | | - cleankey, value = processValue(key, values[key]) |
| 47 | + for key, _value in values.items(): |
| 48 | + cleankey, value = processValue(key, _value) |
49 | 49 | args[cleankey] = value |
50 | 50 | return argparse.Namespace(**args) |
51 | 51 |
|
52 | 52 |
|
53 | 53 | def optparseFormat(values: dict[str, Any]) -> tuple[optparse.Values, list[str]]: |
54 | 54 | """Format args for optparse.""" |
55 | 55 | args = {} |
56 | | - for key in values: |
57 | | - cleankey, value = processValue(key, values[key]) |
| 56 | + for key, _value in values.items(): |
| 57 | + cleankey, value = processValue(key, _value) |
58 | 58 | args[cleankey] = value |
59 | 59 | return (optparse.Values(args), []) |
60 | 60 |
|
61 | 61 |
|
62 | 62 | def getoptFormat(values: dict[str, Any]) -> tuple[list[Any], list[Any]]: |
63 | 63 | """Format args for getopt.""" |
64 | | - return ([processValue(key, values[key]) for key in values if values[key]], []) |
| 64 | + return ([processValue(key, _value) for key, _value in values.items() if _value], []) |
65 | 65 |
|
66 | 66 |
|
67 | 67 | def docoptFormat(values: dict[str, Any]) -> dict[str, Any]: |
68 | 68 | """Format args for docopt.""" |
69 | 69 | import docopt |
70 | 70 |
|
71 | 71 | args = {} |
72 | | - for key in values: |
73 | | - cleankey, value = processValue(key, values[key]) |
| 72 | + for key, _value in values.items(): |
| 73 | + cleankey, value = processValue(key, _value) |
74 | 74 | args[cleankey] = value |
75 | 75 | return docopt.Dict(args) |
76 | 76 |
|
77 | 77 |
|
78 | 78 | def clickFormat(values: dict[str, Any]) -> list[Any]: |
79 | 79 | """Format args for click.""" |
80 | 80 | args = [] |
81 | | - for key in values: |
82 | | - val = str(values[key]) |
| 81 | + for key, _value in values.items(): |
| 82 | + val = str(_value) |
83 | 83 | if not callable(key) and len(val) > 0: |
84 | | - cleankey, value = processValue(key, values[key]) |
| 84 | + cleankey, value = processValue(key, _value) |
85 | 85 | args.extend([cleankey, value]) |
86 | 86 | return args |
87 | 87 |
|
|
0 commit comments