| 431 | |
| 432 | @classmethod |
| 433 | def parse(cls, location, package_only=False): |
| 434 | metayaml = get_meta_yaml_data(location) |
| 435 | package_element = metayaml.get('package') or {} |
| 436 | package_name = package_element.get('name') |
| 437 | package_version = package_element.get('version') |
| 438 | |
| 439 | # FIXME: source is source, not download |
| 440 | source = metayaml.get('source') or {} |
| 441 | download_url = source.get('url') |
| 442 | sha256 = source.get('sha256') |
| 443 | |
| 444 | about = metayaml.get('about') or {} |
| 445 | homepage_url = about.get('home') |
| 446 | extracted_license_statement = about.get('license') |
| 447 | description = about.get('summary') |
| 448 | vcs_url = about.get('dev_url') |
| 449 | |
| 450 | dependencies = [] |
| 451 | extra_data = {} |
| 452 | requirements = metayaml.get('requirements') or {} |
| 453 | for scope, reqs in requirements.items(): |
| 454 | # requirements format is like: |
| 455 | # (u'run', [u'mccortex ==1.0', u'nextflow ==19.01.0', u'cortexpy |
| 456 | # ==0.45.7', u'kallisto ==0.44.0', u'bwa', u'pandas', |
| 457 | # u'progressbar2', u'python >=3.6'])]) |
| 458 | for req in reqs: |
| 459 | name, _, requirement = req.partition(" ") |
| 460 | version = None |
| 461 | if requirement.startswith("=="): |
| 462 | _, version = requirement.split("==") |
| 463 | |
| 464 | # requirements may have namespace, version too |
| 465 | # - conda-forge::numpy=1.15.4 |
| 466 | namespace = None |
| 467 | if "::" in name: |
| 468 | namespace, name = name.split("::") |
| 469 | |
| 470 | is_pinned = False |
| 471 | if "=" in name: |
| 472 | name, version = name.split("=") |
| 473 | is_pinned = True |
| 474 | requirement = f"={version}" |
| 475 | |
| 476 | if name in ('pip', 'python'): |
| 477 | if not scope in extra_data: |
| 478 | extra_data[scope] = [req] |
| 479 | else: |
| 480 | extra_data[scope].append(req) |
| 481 | continue |
| 482 | |
| 483 | purl = PackageURL( |
| 484 | type=cls.default_package_type, |
| 485 | name=name, |
| 486 | namespace=namespace, |
| 487 | version=version, |
| 488 | ) |
| 489 | if "run" in scope: |
| 490 | is_runtime = True |