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

Class MavenPom

src/packagedcode/maven.py:419–911  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417
418
419class MavenPom(pom.Pom):
420
421 def __init__(self, location=None, text=None):
422 """
423 Build a POM from a location or unicode text.
424 """
425 assert (location or text) and (not (location and text))
426
427 if location:
428 try:
429 with open(location) as fh:
430 xml_text = fh.read()
431 except UnicodeDecodeError as _a:
432 xml_text = analysis.unicode_text(location)
433 else:
434 xml_text = text
435 xml_text = strip_namespace(xml_text)
436 xml_text = xml_text.encode('utf-8')
437 if TRACE:
438 logger.debug('MavenPom.__init__: xml_text: {}'.format(xml_text))
439
440 self._pom_data = lxml.etree.fromstring(xml_text, parser=pom.POM_PARSER) # NOQA
441
442 # collect and then remove XML comments from the XML elements tree
443 self.comments = self._get_comments()
444 lxml.etree.strip_tags(self._pom_data, lxml.etree.Comment) # NOQA
445
446 # FIXME: we do not use a client for now.
447 # There are pending issues at pymaven to address this
448 self._client = None
449
450 self.model_version = self._get_attribute('modelVersion')
451 if not self.model_version:
452 # for older POM version 3
453 self.model_version = self._get_attribute('pomVersion')
454 self.group_id = self._get_attribute('groupId')
455 self.artifact_id = self._get_attribute('artifactId')
456 if TRACE:
457 logger.debug('MavenPom.__init__: self.artifact_id: {}'.format(self.artifact_id))
458
459 self.version = self._get_attribute('version')
460 self.classifier = self._get_attribute('classifier')
461 self.packaging = self._get_attribute('packaging') or 'jar'
462 self.name = self._get_attribute('name')
463 self.description = self._get_attribute('description')
464 self.inception_year = self._get_attribute('inceptionYear')
465 self.url = self._get_attribute('url')
466 self.organization_name = self._get_attribute('organization/name')
467 self.organization_url = self._get_attribute('organization/url')
468 self.licenses = list(self._find_licenses())
469 self.developers = list(self._find_parties('developers/developer'))
470 self.contributors = list(self._find_parties('contributors/contributor'))
471 self.mailing_lists = list(self._find_mailing_lists())
472 self.scm = self._find_scm()
473 self.issue_management = self._find_issue_management()
474 self.ci_management = self._find_ci_management()
475 self.distribution_management = self._find_distribution_management()
476 self.repositories = list(self._find_repositories('repositories/repository'))

Callers 1

get_maven_pomFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected