Fetch and parse package index from URL with validation
(self, url: str)
| 451 | raise PackageParsingError(f"Invalid JSON format: {e}") |
| 452 | |
| 453 | def parse_from_url(self, url: str) -> PackageIndex: |
| 454 | """Fetch and parse package index from URL with validation""" |
| 455 | try: |
| 456 | print(f"Fetching package index from: {url}") |
| 457 | with urlopen(url, timeout=self.timeout) as response: |
| 458 | content = response.read() |
| 459 | json_str = content.decode("utf-8") |
| 460 | |
| 461 | return self.parse_package_index(json_str) |
| 462 | |
| 463 | except KeyboardInterrupt as ki: |
| 464 | handle_keyboard_interrupt(ki) |
| 465 | raise |
| 466 | except Exception as e: |
| 467 | raise PackageParsingError(f"Error fetching package index from {url}: {e}") |
| 468 | |
| 469 | async def parse_from_url_async(self, url: str) -> PackageIndex: |
| 470 | """Async version of URL parsing""" |