|
1 | 1 | #!/usr/bin/env python3
|
2 |
| -from collections.abc import Mapping, Sequence |
3 | 2 | import json
|
4 | 3 | import logging
|
5 | 4 | import os
|
6 |
| -from pathlib import Path, PurePath |
7 | 5 | import shlex
|
8 | 6 | import tempfile
|
| 7 | +from collections.abc import Mapping, Sequence |
| 8 | +from pathlib import Path, PurePath |
9 | 9 | from typing import AnyStr, cast
|
10 | 10 | from urllib.parse import ParseResult, urlparse, urlunparse
|
11 | 11 |
|
|
20 | 20 | )
|
21 | 21 | JsonObject = dict[str, JsonValue]
|
22 | 22 |
|
| 23 | + |
23 | 24 | def init_config(workspace=None):
|
24 | 25 | global CONFIG_DATA, CONFIG_SOURCE
|
25 | 26 | if CONFIG_DATA is not None:
|
@@ -91,12 +92,12 @@ def init_config(workspace=None):
|
91 | 92 |
|
92 | 93 |
|
93 | 94 | def combine_config(
|
94 |
| - workspace: str | None, |
95 |
| - config: JsonObject, |
96 |
| - combined_config: JsonObject, |
97 |
| - config_source: str, |
98 |
| - child_uri: ParseResult | None = None |
99 |
| - ) -> str: |
| 95 | + workspace: str | None, |
| 96 | + config: JsonObject, |
| 97 | + combined_config: JsonObject, |
| 98 | + config_source: str, |
| 99 | + child_uri: ParseResult | None = None, |
| 100 | +) -> str: |
100 | 101 | workspace_path = Path(workspace) if workspace else None
|
101 | 102 | parsed_uri: ParseResult | None = None
|
102 | 103 | extends = cast(str | Sequence[str], config["EXTENDS"])
|
@@ -124,17 +125,15 @@ def combine_config(
|
124 | 125 | extends_config_data,
|
125 | 126 | combined_config,
|
126 | 127 | config_source,
|
127 |
| - parsed_uri |
| 128 | + parsed_uri, |
128 | 129 | )
|
129 | 130 | combined_config.update(config)
|
130 | 131 | return config_source
|
131 | 132 |
|
132 | 133 |
|
133 | 134 | def download_config(uri: AnyStr) -> JsonObject:
|
134 | 135 | r = requests.get(uri, allow_redirects=True)
|
135 |
| - assert ( |
136 |
| - r.status_code == 200 |
137 |
| - ), f"Unable to retrieve EXTENDS config file {uri!r}" |
| 136 | + assert r.status_code == 200, f"Unable to retrieve EXTENDS config file {uri!r}" |
138 | 137 | return yaml.safe_load(r.content)
|
139 | 138 |
|
140 | 139 |
|
|
0 commit comments