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

Method parse

src/packagedcode/conan.py:188–216  ·  view source on GitHub ↗
(cls, location, package_only=False)

Source from the content-addressed store, hash-verified

186
187 @classmethod
188 def parse(cls, location, package_only=False):
189 with io.open(location, encoding="utf-8") as loc:
190 conan_data = loc.read()
191
192 conan_data = saneyaml.load(conan_data)
193 sources = conan_data.get("sources", {})
194
195 for version, source in sources.items():
196 sha256 = source.get("sha256", None)
197 source_urls = source.get("url")
198 if not source_urls:
199 continue
200
201 url = None
202 if isinstance(source_urls, str):
203 url = source_urls
204 elif isinstance(source_urls, list):
205 url = source_urls[0]
206
207 package_data = dict(
208 datasource_id=cls.datasource_id,
209 type=cls.default_package_type,
210 primary_language=cls.default_primary_language,
211 namespace=None,
212 version=version,
213 download_url=url,
214 sha256=sha256,
215 )
216 yield models.PackageData.from_data(package_data, package_only)
217
218
219 @classmethod

Callers

nothing calls this directly

Calls 5

from_dataMethod · 0.80
getMethod · 0.65
openMethod · 0.45
readMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected