(self)
| 212 | _log_by_download_target = attr.ib() # type: Mapping[DownloadTarget, str] |
| 213 | |
| 214 | def finalize_log(self): |
| 215 | # type: () -> None |
| 216 | if not self.log: |
| 217 | return |
| 218 | |
| 219 | target_count = len(self._log_by_download_target) |
| 220 | if target_count <= 1: |
| 221 | return |
| 222 | |
| 223 | with safe_open(self.log.path, "a") as out_fp: |
| 224 | for index, (download_target, log) in enumerate( |
| 225 | self._log_by_download_target.items(), start=1 |
| 226 | ): |
| 227 | prefix = "{index}/{count}]{target}".format( |
| 228 | index=index, count=target_count, target=download_target.id() |
| 229 | ) |
| 230 | if not os.path.exists(log): |
| 231 | print( |
| 232 | "{prefix}: WARNING: no Pip log was generated!".format(prefix=prefix), |
| 233 | file=out_fp, |
| 234 | ) |
| 235 | continue |
| 236 | |
| 237 | with open(log) as in_fp: |
| 238 | for line in in_fp: |
| 239 | out_fp.write("{prefix}: {line}".format(prefix=prefix, line=line)) |
| 240 | |
| 241 | def get_log(self, download_target): |
| 242 | # type: (DownloadTarget) -> Optional[str] |
no test coverage detected