|
6 | 6 | from multiprocessing import Pool, cpu_count
|
7 | 7 | from os.path import expanduser
|
8 | 8 | from time import sleep
|
9 |
| -from typing import Tuple |
| 9 | +from typing import Tuple, Optional |
10 | 10 |
|
11 | 11 | from atcodertools.codegen.code_gen_config import CodeGenConfig
|
12 | 12 | from atcodertools.codegen.cpp_code_generator import CppCodeGenerator
|
@@ -213,17 +213,18 @@ def check_lang(lang: str):
|
213 | 213 | os.path.join(script_dir_path, "./atcodertools-default.toml"))
|
214 | 214 |
|
215 | 215 |
|
216 |
| -def get_code_gen_config(config_path: str = None): |
| 216 | +def get_code_gen_config(config_path: Optional[str] = None): |
| 217 | + def _load(path: str): |
| 218 | + logging.info("Going to load {} as config".format(path)) |
| 219 | + return CodeGenConfig.load(path) |
| 220 | + |
217 | 221 | if config_path:
|
218 |
| - logging.info("Going to load {} as config".format(config_path)) |
219 |
| - return CodeGenConfig.load(config_path) |
| 222 | + return _load(config_path) |
| 223 | + |
220 | 224 | if os.path.exists(PRIMARY_DEFAULT_CONFIG_PATH):
|
221 |
| - logging.info("Going to load {} as config".format( |
222 |
| - PRIMARY_DEFAULT_CONFIG_PATH)) |
223 |
| - return CodeGenConfig.load(PRIMARY_DEFAULT_CONFIG_PATH) |
224 |
| - logging.info("Going to load {} as config".format( |
225 |
| - SECONDARY_DEFAULT_CONFIG_PATH)) |
226 |
| - return CodeGenConfig.load(SECONDARY_DEFAULT_CONFIG_PATH) |
| 225 | + return _load(PRIMARY_DEFAULT_CONFIG_PATH) |
| 226 | + |
| 227 | + return _load(SECONDARY_DEFAULT_CONFIG_PATH) |
227 | 228 |
|
228 | 229 |
|
229 | 230 | def main(prog, args):
|
@@ -280,7 +281,9 @@ def main(prog, args):
|
280 | 281 | help="{0}{1}{2}".format("file path to your config file\n",
|
281 | 282 | "[Default (Primary)] {}\n".format(
|
282 | 283 | PRIMARY_DEFAULT_CONFIG_PATH),
|
283 |
| - "[Default (Secondary)] {}\n".format(SECONDARY_DEFAULT_CONFIG_PATH))) |
| 284 | + "[Default (Secondary)] {}\n".format( |
| 285 | + SECONDARY_DEFAULT_CONFIG_PATH)) |
| 286 | + ) |
284 | 287 |
|
285 | 288 | args = parser.parse_args(args)
|
286 | 289 |
|
|
0 commit comments