(
cls,
download_target, # type: DownloadTarget
report, # type: str
)
| 247 | class Report(object): |
| 248 | @classmethod |
| 249 | def parse( |
| 250 | cls, |
| 251 | download_target, # type: DownloadTarget |
| 252 | report, # type: str |
| 253 | ): |
| 254 | # type: (...) -> Report |
| 255 | |
| 256 | with open(report) as fp: |
| 257 | data = json.load(fp) |
| 258 | |
| 259 | project_metadata = [] # type: List[ProjectMetadata] |
| 260 | for distribution in data["install"]: |
| 261 | metadata = distribution["metadata"] |
| 262 | project_metadata.append( |
| 263 | ProjectMetadata( |
| 264 | project_name=ProjectName(metadata["name"]), |
| 265 | version=Version(metadata["version"]), |
| 266 | requires_python=SpecifierSet(metadata.get("requires_python", "")), |
| 267 | requires_dists=tuple( |
| 268 | Requirement.parse(requirement) |
| 269 | for requirement in metadata.get("requires_dist", ()) |
| 270 | ), |
| 271 | ) |
| 272 | ) |
| 273 | return cls( |
| 274 | download_target=download_target, |
| 275 | metadata={metadata.project_name: metadata for metadata in project_metadata}, |
| 276 | ) |
| 277 | |
| 278 | download_target = attr.ib() # type: DownloadTarget |
| 279 | metadata = attr.ib() # type: Mapping[ProjectName, ProjectMetadata] |
no test coverage detected