Skip to content

Commit

Permalink
Merge pull request aboutcode-org#3682 from nexB/update-package-handlers
Browse files Browse the repository at this point in the history
Update package handlers
  • Loading branch information
AyanSinhaMahapatra authored Mar 15, 2024
2 parents ea8953b + 310fdeb commit c80e502
Show file tree
Hide file tree
Showing 30 changed files with 232 additions and 13,679 deletions.
10 changes: 2 additions & 8 deletions src/packagedcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from packagedcode import godeps
from packagedcode import golang
from packagedcode import haxe
from packagedcode import jar_manifest
from packagedcode import maven
from packagedcode import misc
from packagedcode import npm
Expand Down Expand Up @@ -84,6 +83,7 @@
cran.CranDescriptionFileHandler,

debian_copyright.DebianCopyrightFileInPackageHandler,
debian_copyright.StandaloneDebianCopyrightFileHandler,
debian.DebianDscFileHandler,

debian.DebianControlFileInExtractedDebHandler,
Expand Down Expand Up @@ -216,13 +216,7 @@

debian.DebianInstalledFilelistHandler,
debian.DebianInstalledMd5sumFilelistHandler,
debian.DebianInstalledStatusDatabaseHandler,
debian.DebianControlFileInSourceHandler,
debian.DebianDscFileHandler,
debian.DebianSourcePackageTarballHandler,
debian.DebianSourcePackageMetadataTarballHandler,
debian.DebianDebPackageHandler,
debian_copyright.StandaloneDebianCopyrightFileHandler
debian.DebianInstalledStatusDatabaseHandler
]

if on_linux:
Expand Down
10 changes: 1 addition & 9 deletions src/packagedcode/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def logger_debug(*args):
)


class AutotoolsConfigureHandler(models.DatafileHandler):
class AutotoolsConfigureHandler(models.NonAssemblableDatafileHandler):
datasource_id = 'autotools_configure'
path_patterns = ('*/configure', '*/configure.ac',)
default_package_type = 'autotools'
Expand All @@ -74,14 +74,6 @@ def parse(cls, location):
version=version,
)

@classmethod
def assign_package_to_resources(cls, package, resource, codebase, package_adder):
models.DatafileHandler.assign_package_to_parent_tree(
package=package,
resource=resource,
codebase=codebase,
package_adder=package_adder,
)


def check_rule_name_ending(rule_name, starlark_rule_types=('binary', 'library')):
Expand Down
31 changes: 28 additions & 3 deletions src/packagedcode/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,10 @@ def parse_debian_files_list(location, datasource_id, package_type):
name, _, arch = filename.partition(':')
qualifiers['arch'] = arch
else:
name = filename
name = None
# For DebianMd5sumFilelistInPackageHandler we cannot infer name
if not name == "md5sums":
name = filename

file_references = []
with open(location) as info_file:
Expand Down Expand Up @@ -643,12 +646,14 @@ def build_package_data(debian_data, datasource_id, package_type='deb', distro=No

maintainer = debian_data.get('maintainer')
if maintainer:
party = models.Party(role='maintainer', name=maintainer)
maintainer_name, maintainer_email = parse_debian_maintainers(maintainer)
party = models.Party(role='maintainer', name=maintainer_name, email=maintainer_email)
parties.append(party)

orig_maintainer = debian_data.get('original_maintainer')
if orig_maintainer:
party = models.Party(role='original_maintainer', name=orig_maintainer)
maintainer_name, maintainer_email = parse_debian_maintainers(orig_maintainer)
party = models.Party(role='maintainer', name=maintainer_name, email=maintainer_email)
parties.append(party)

keywords = []
Expand Down Expand Up @@ -708,6 +713,26 @@ def build_package_data(debian_data, datasource_id, package_type='deb', distro=No
)


def parse_debian_maintainers(maintainer):
"""
Get name and email values from a debian maintainer string.
Example string:
Debian systemd Maintainers <[email protected]>
"""
email_wrappers = ["<", ">"]
has_email = "@" in maintainer and all([
True
for char in email_wrappers
if char in maintainer
])
if not has_email:
return maintainer, None

name, _, email = maintainer.rpartition("<")
return name.rstrip(" "), email.rstrip(">")


def populate_debian_namespace(packages):
"""
For an iterable of debian `packages`, populate the
Expand Down
36 changes: 0 additions & 36 deletions tests/formattedcode/data/cyclonedx/simple-icu-expected.json

This file was deleted.

Loading

0 comments on commit c80e502

Please sign in to comment.