MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / find_root_resource

Function find_root_resource

src/packagedcode/utils.py:182–194  ·  view source on GitHub ↗

Return the resource for the root directory of this filesystem or None, given a ``resource`` in ``codebase`` with a possible resource root-relative ``path`` (e.g. extending from the root directory we are looking for).

(path, resource, codebase)

Source from the content-addressed store, hash-verified

180
181
182def find_root_resource(path, resource, codebase):
183 """
184 Return the resource for the root directory of this filesystem or None, given
185 a ``resource`` in ``codebase`` with a possible resource root-relative
186 ``path`` (e.g. extending from the root directory we are looking for).
187 """
188 if not resource.path.endswith(path):
189 return
190 for _seg in path.split('/'):
191 resource = resource.parent(codebase)
192 if not resource:
193 return
194 return resource
195
196
197def yield_dependencies_from_package_data(package_data, datafile_path, package_uid):

Callers 1

find_root_from_pathsFunction · 0.85

Calls 2

parentMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected