MCPcopy
hub / github.com/pex-tool/pex / find

Method find

pex/finders.py:35–59  ·  view source on GitHub ↗
(
        cls,
        dist,  # type: Distribution
        name,  # type: str
    )

Source from the content-addressed store, hash-verified

33class 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

Callers 1

Calls 5

script_nameFunction · 0.90
open_zipFunction · 0.90
data_pathMethod · 0.80
stashed_pathMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected