| ... | ... |
@@ -160,6 +160,14 @@ CATEGORY_ATTRIBS = {
|
| 160 | 160 |
], |
| 161 | 161 |
} |
| 162 | 162 |
REQUIRE = f"require[{MAYBE('api','gl')} and {MAYBE('profile','core')}]"
|
| 163 |
+REMOVE = f"remove[{ MAYBE('api','gl')} and {MAYBE('profile','core')}]"
|
|
| 164 |
+CHANGE_PREFIXES = [ |
|
| 165 |
+ [REQUIRE, '' ], |
|
| 166 |
+ [REMOVE, '<'], |
|
| 167 |
+] |
|
| 168 |
+KEY_SUBS = [ |
|
| 169 |
+ *[[f'^{prefix}', f''] for _, prefix in CHANGE_PREFIXES],
|
|
| 170 |
+] |
|
| 163 | 171 |
|
| 164 | 172 |
|
| 165 | 173 |
## Helpers |
| ... | ... |
@@ -203,6 +211,13 @@ def removeprefix(prefix, string): |
| 203 | 211 |
return string |
| 204 | 212 |
|
| 205 | 213 |
|
| 214 |
+### `key` |
|
| 215 |
+def key(item): |
|
| 216 |
+ for sub in KEY_SUBS: |
|
| 217 |
+ item = re.sub(*sub, item) |
|
| 218 |
+ return item |
|
| 219 |
+ |
|
| 220 |
+ |
|
| 206 | 221 |
### `download` |
| 207 | 222 |
def download(path, exit_on_failure=True): |
| 208 | 223 |
remote = urllib.parse.urljoin(REGISTRY_URL, path) |
| ... | ... |
@@ -327,12 +342,13 @@ def supports(xml, name): |
| 327 | 342 |
if xml.xpath(f"{category}[@{attrib}='{name}']"):
|
| 328 | 343 |
return ['EXTENSION'] |
| 329 | 344 |
supports_ = [ |
| 330 |
- support |
|
| 345 |
+ f'{prefix}{support}'
|
|
| 331 | 346 |
for category, attrib in CATEGORY_ATTRIBS.values() |
| 347 |
+ for change, prefix in CHANGE_PREFIXES |
|
| 332 | 348 |
for support in |
| 333 |
- xml.xpath(f"{category}/{REQUIRE}/*[@name='{name}']/../../@{attrib}")
|
|
| 349 |
+ xml.xpath(f"{category}/{change}/*[@name='{name}']/../../@{attrib}")
|
|
| 334 | 350 |
] |
| 335 |
- return sorted(supports_) |
|
| 351 |
+ return sorted(supports_, key=key) |
|
| 336 | 352 |
|
| 337 | 353 |
|
| 338 | 354 |
### `names` |