|
6 | 6 |
|
7 | 7 | def _validate_metadata_sha_digest(link, filename, metadata_sha_digests): |
8 | 8 | """ |
9 | | - Validate data-dist-info-metadata attribute for a release link. |
| 9 | + Validate data-dist-info-metadata and data-core-metadata attributes for a release link. |
10 | 10 | """ |
11 | | - data_dist_info_metadata = link.get("data-dist-info-metadata") |
| 11 | + expected_metadata_sha = metadata_sha_digests.get(filename) |
| 12 | + expected_attr = f"sha256={expected_metadata_sha}" if expected_metadata_sha else None |
12 | 13 |
|
13 | | - if expected_metadata_sha := metadata_sha_digests.get(filename): |
14 | | - expected_attr = f"sha256={expected_metadata_sha}" |
15 | | - if data_dist_info_metadata != expected_attr: |
16 | | - return ( |
17 | | - f"\nFile {filename} has incorrect data-dist-info-metadata: " |
18 | | - f"expected '{expected_attr}', got '{data_dist_info_metadata}'" |
19 | | - ) |
20 | | - else: |
21 | | - if data_dist_info_metadata: |
22 | | - return ( |
23 | | - f"\nFile {filename} should not have data-dist-info-metadata " |
24 | | - f"but has '{data_dist_info_metadata}'" |
25 | | - ) |
26 | | - return "" |
| 14 | + msgs = "" |
| 15 | + for attr_name in ["data-dist-info-metadata", "data-core-metadata"]: |
| 16 | + attr_value = link.get(attr_name) |
| 17 | + if attr_value != expected_attr: |
| 18 | + if expected_attr: |
| 19 | + msgs += ( |
| 20 | + f"\nFile {filename} has incorrect {attr_name}: " |
| 21 | + f"expected '{expected_attr}', got '{attr_value}'" |
| 22 | + ) |
| 23 | + else: |
| 24 | + msgs += f"\nFile {filename} should not have {attr_name} but has '{attr_value}'" |
| 25 | + return msgs |
27 | 26 |
|
28 | 27 |
|
29 | 28 | def ensure_simple(simple_url, packages, sha_digests=None, metadata_sha_digests=None): |
|
0 commit comments