|
31 | 31 | from typing import Mapping |
32 | 32 | from typing import Set |
33 | 33 | from typing import Tuple |
34 | | -from urllib.error import HTTPError |
35 | | -from urllib.request import urlopen |
36 | | -import requests |
37 | 34 |
|
38 | 35 | from dephell_specifier import RangeSpecifier |
39 | 36 | from packageurl import PackageURL |
| 37 | +import requests |
40 | 38 | from schema import Or |
41 | 39 | from schema import Regex |
42 | 40 | from schema import Schema |
@@ -94,8 +92,7 @@ def set_api(self, packages): |
94 | 92 |
|
95 | 93 | def _fetch(self) -> Mapping[str, Any]: |
96 | 94 | if create_etag(data_src=self, url=self.config.url, etag_key="ETag"): |
97 | | - with urlopen(self.config.url) as response: |
98 | | - return json.load(response) |
| 95 | + return requests.get(self.config.url).json() |
99 | 96 |
|
100 | 97 | return [] |
101 | 98 |
|
@@ -142,13 +139,13 @@ def updated_advisories(self) -> Set[Advisory]: |
142 | 139 | def categorize_versions( |
143 | 140 | package_name: str, |
144 | 141 | all_versions: Set[str], |
145 | | - version_specs: Iterable[str], |
| 142 | + version_ranges: Iterable[str], |
146 | 143 | ) -> Tuple[Set[PackageURL], Set[PackageURL]]: |
147 | 144 | """ |
148 | 145 | :return: impacted, resolved purls |
149 | 146 | """ |
150 | 147 | impacted_versions, impacted_purls = set(), set() |
151 | | - ranges = [RangeSpecifier(s) for s in version_specs] |
| 148 | + ranges = [RangeSpecifier(s) for s in version_ranges] |
152 | 149 |
|
153 | 150 | for version in all_versions: |
154 | 151 | if any([version in r for r in ranges]): |
|
0 commit comments