(args: argparse.Namespace)
| 91 | |
| 92 | |
| 93 | def run(args: argparse.Namespace) -> None: |
| 94 | output_root = Path(args.output).expanduser().resolve() |
| 95 | output_root.mkdir(parents=True, exist_ok=True) |
| 96 | |
| 97 | resp = requests.get(APPCAST_URL, timeout=30) |
| 98 | resp.raise_for_status() |
| 99 | |
| 100 | snapshot_path = appcast_snapshot_path(output_root) |
| 101 | snapshot_path.parent.mkdir(parents=True, exist_ok=True) |
| 102 | with snapshot_path.open("xb") as snapshot: |
| 103 | snapshot.write(resp.content) |
| 104 | print(f"Archived appcast {snapshot_path}") |
| 105 | |
| 106 | root = etree.fromstring( |
| 107 | resp.content, parser=etree.XMLParser(resolve_entities=False, no_network=True) |
| 108 | ) |
| 109 | for item in root.findall("./channel/item"): |
| 110 | sparkle_version = safe_path_component(item.find(sparkle_name("version")).text) |
| 111 | short_version = safe_path_component( |
| 112 | item.find(sparkle_name("shortVersionString")).text |
| 113 | ) |
| 114 | version_dir = output_root / "versions" / f"{sparkle_version}-{short_version}" |
| 115 | |
| 116 | try: |
| 117 | process_item(version_dir, item) |
| 118 | except Exception as e: |
| 119 | print(f"error {e} for {version_dir}") |
| 120 | |
| 121 | |
| 122 | def main() -> None: |
no test coverage detected