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

Method parse

src/packagedcode/cocoapods.py:543–626  ·  view source on GitHub ↗
(cls, location, package_only=False)

Source from the content-addressed store, hash-verified

541
542 @classmethod
543 def parse(cls, location, package_only=False):
544 with open(location) as psj:
545 data = json.load(psj)
546
547 name = data.get('name')
548 version = data.get('version')
549 summary = data.get('summary', '')
550 description = data.get('description', '')
551 homepage_url = data.get('homepage')
552
553 lic = data.get('license')
554 if isinstance(lic, dict):
555 extracted_license_statement = ' '.join(list(lic.values()))
556 else:
557 extracted_license_statement = lic
558
559 source = data.get('source')
560 vcs_url = None
561 download_url = None
562
563 if isinstance(source, dict):
564 git_url = source.get('git', '')
565 http_url = source.get('http', '')
566 if git_url:
567 vcs_url = git_url
568 elif http_url:
569 download_url = http_url
570 elif isinstance(source, str):
571 if not vcs_url:
572 vcs_url = source
573
574 authors = data.get('authors') or {}
575
576 if summary and not description.startswith(summary):
577 desc = [summary]
578 if description:
579 desc += [description]
580 description = '. '.join(desc)
581
582 parties = []
583 if authors:
584 if isinstance(authors, dict):
585 for key, value in authors.items():
586 party = models.Party(
587 type=models.party_org,
588 name=key,
589 url=value + '.com',
590 role='owner'
591 )
592 parties.append(party)
593 else:
594 party = models.Party(
595 type=models.party_org,
596 name=authors,
597 role='owner'
598 )
599 parties.append(party)
600

Callers

nothing calls this directly

Calls 7

from_dataMethod · 0.80
get_urlsFunction · 0.70
getMethod · 0.65
loadMethod · 0.45
joinMethod · 0.45
valuesMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected