(
cls,
dist, # type: Distribution
name, # type: str
)
| 33 | class DistributionScript(object): |
| 34 | @classmethod |
| 35 | def find( |
| 36 | cls, |
| 37 | dist, # type: Distribution |
| 38 | name, # type: str |
| 39 | ): |
| 40 | # type: (...) -> Optional[DistributionScript] |
| 41 | if dist.type is DistributionType.WHEEL: |
| 42 | script_path = Wheel.load(dist.location).data_path("scripts", script_name(name)) |
| 43 | with open_zip(dist.location) as zfp: |
| 44 | try: |
| 45 | zfp.getinfo(script_path) |
| 46 | except KeyError: |
| 47 | return None |
| 48 | elif dist.type is DistributionType.INSTALLED: |
| 49 | script_path = InstalledWheel.load(dist.location).stashed_path( |
| 50 | SCRIPT_DIR, script_name(name) |
| 51 | ) |
| 52 | if not os.path.isfile(script_path): |
| 53 | return None |
| 54 | else: |
| 55 | raise ValueError( |
| 56 | "Can only probe .whl files and installed wheel chroots for scripts; " |
| 57 | "given sdist: {sdist}".format(sdist=dist.location) |
| 58 | ) |
| 59 | return cls(dist=dist, path=script_path) |
| 60 | |
| 61 | dist = attr.ib() # type: Distribution |
| 62 | path = attr.ib() # type: str |
no test coverage detected