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