|
14 | 14 | from contextlib import contextmanager
|
15 | 15 | from os import path
|
16 | 16 | from tarfile import TarFile, is_tarfile
|
17 |
| -from typing import Callable, Generator, Iterable, List, Optional, Set, Union |
| 17 | +from typing import ( |
| 18 | + Callable, |
| 19 | + Dict, |
| 20 | + Generator, |
| 21 | + Iterable, |
| 22 | + List, |
| 23 | + Optional, |
| 24 | + Set, |
| 25 | + Union, |
| 26 | +) |
18 | 27 | from zipfile import ZipFile, is_zipfile
|
19 | 28 |
|
20 |
| -from extract_utils.fixups import fixups_type, fixups_user_type |
21 | 29 | from extract_utils.tools import (
|
22 | 30 | brotli_path,
|
23 | 31 | lpunpack_path,
|
|
51 | 59 |
|
52 | 60 | extract_fn_type = Callable[['ExtractCtx', str, str], Optional[str]]
|
53 | 61 | extract_fns_value_type = Union[extract_fn_type, List[extract_fn_type]]
|
54 |
| -extract_fns_user_type = fixups_user_type[extract_fns_value_type] |
55 |
| -extract_fns_type = fixups_type[extract_fns_value_type] |
| 62 | +extract_fns_user_type = Dict[str, extract_fns_value_type] |
56 | 63 |
|
57 | 64 |
|
58 | 65 | class ExtractCtx:
|
59 | 66 | def __init__(
|
60 | 67 | self,
|
61 | 68 | keep_dump=False,
|
62 |
| - extract_fns: Optional[extract_fns_type] = None, |
| 69 | + extract_fns: Optional[extract_fns_user_type] = None, |
63 | 70 | extract_partitions: Optional[List[str]] = None,
|
64 | 71 | firmware_partitions: Optional[List[str]] = None,
|
65 | 72 | firmware_files: Optional[List[str]] = None,
|
@@ -134,7 +141,7 @@ def find_files(
|
134 | 141 |
|
135 | 142 |
|
136 | 143 | def should_extract_pattern_file_name(
|
137 |
| - extract_fns: extract_fns_type, file_name: str |
| 144 | + extract_fns: extract_fns_user_type, file_name: str |
138 | 145 | ):
|
139 | 146 | for extract_pattern in extract_fns:
|
140 | 147 | match = re.match(extract_pattern, file_name)
|
@@ -172,7 +179,7 @@ def find_alternate_partitions(
|
172 | 179 | def _filter_files(
|
173 | 180 | extract_partitions: List[str],
|
174 | 181 | extract_file_names: List[str],
|
175 |
| - extract_fns: extract_fns_type, |
| 182 | + extract_fns: extract_fns_user_type, |
176 | 183 | file_paths: List[str],
|
177 | 184 | found_partitions: Set[str],
|
178 | 185 | ) -> List[str]:
|
@@ -208,7 +215,7 @@ def filter_files(
|
208 | 215 | partition_lists: List[List[str]],
|
209 | 216 | file_name_lists: List[List[str]],
|
210 | 217 | found_partitions: Set[str],
|
211 |
| - extract_fns: extract_fns_type, |
| 218 | + extract_fns: extract_fns_user_type, |
212 | 219 | file_paths: List[str],
|
213 | 220 | ) -> List[str]:
|
214 | 221 | extract_partitions = sum(partition_lists, [])
|
|
0 commit comments