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

Method _resolve_resource_path

pex/pex.py:155–181  ·  view source on GitHub ↗
(
        cls,
        name,  # type: str
        resource,  # type: str
    )

Source from the content-addressed store, hash-verified

153
154 @classmethod
155 def _resolve_resource_path(
156 cls,
157 name, # type: str
158 resource, # type: str
159 ):
160 # type: (...) -> str
161
162 rel_path = os.path.normpath(os.path.join(*resource.split("/")))
163 if os.path.isabs(resource) or rel_path.startswith(os.pardir):
164 raise cls.ResourceBindingError(
165 "The following resource binding spec is invalid: {name}={resource}\n"
166 "The resource path {resource} must be relative to the `sys.path`.".format(
167 name=name, resource=resource
168 )
169 )
170
171 for entry in sys.path:
172 value = os.path.join(entry, rel_path)
173 if os.path.isfile(value):
174 return value
175
176 raise cls.ResourceBindingError(
177 "There was no resource file {resource} found on the `sys.path` corresponding to "
178 "the given resource binding spec `{name}={resource}`".format(
179 resource=resource, name=name
180 )
181 )
182
183 @classmethod
184 def _clean_environment(cls, env=None, strip_pex_env=True):

Callers 1

_executeMethod · 0.95

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected