Skip to content

Commit 8c73fcb

Browse files
authored
Merge pull request #205 from Mab879/cy25q4_update
Fix import_zips
2 parents 13eef21 + db8cc14 commit 8c73fcb

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

utils/import_zips.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,24 @@ def main() -> int:
5959
full_zip_path = download_root / current_zip
6060
with zipfile.ZipFile(full_zip_path, "r") as z:
6161
product_regex = r"U_(?P<product>.+)_V(?P<version>\d+)R(?P<release>\d+)_(?P<type>STIG|SRG)\.zip"
62-
matches = re.matches = re.search(product_regex, current_zip)
63-
if not matches:
62+
product_regex_matches = re.match(product_regex, current_zip)
63+
if not product_regex_matches:
6464
print(
6565
f"skipping {full_zip_path} since the file name doesn't match the normal pattern"
6666
)
6767
continue
68-
matches = matches.groupdict()
69-
version = matches["version"]
70-
release = matches["release"]
68+
matches_dict = product_regex_matches.groupdict()
69+
version = matches_dict["version"]
70+
release = matches_dict["release"]
71+
product = matches_dict["product"]
7172
short_version = f"v{version}r{release}"
73+
if product not in disa_to_shortname:
74+
print(f"skipping {product} as it is not in known products")
75+
continue
76+
short_name = disa_to_shortname[product]
7277
for file_info in z.infolist():
7378
if file_info.filename.endswith(".xml"):
7479
with z.open(file_info) as file:
75-
if matches["product"] not in disa_to_shortname:
76-
print(
77-
f"skipping {matches['product']} as it is not in known products"
78-
)
79-
continue
80-
short_name = disa_to_shortname[matches["product"]]
8180
filename = f"{short_version}.xml"
8281
output_path = root / "products" / short_name / filename
8382
if not output_path.exists():
@@ -101,4 +100,4 @@ def main() -> int:
101100

102101

103102
if __name__ == "__main__":
104-
raise sys.exit(main())
103+
raise SystemExit(main())

0 commit comments

Comments
 (0)