Skip to content

Commit 366c66b

Browse files
Support ignored_resources attribute in ABOUT files #809 (#810)
Reference: #809 Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent df620aa commit 366c66b

File tree

5 files changed

+347
-51
lines changed

5 files changed

+347
-51
lines changed

scanpipe/pipes/d2d.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,12 +614,21 @@ def _map_about_file_resource(project, about_file_resource, to_resources):
614614
# Cannot map anything without the about_resource value.
615615
return
616616

617+
ignored_resources = None
618+
if extra_data := package_data.get("extra_data"):
619+
ignored_resources = extra_data.get("ignored_resources")
620+
617621
# Fetch all resources that are covered by the .ABOUT file.
618622
codebase_resources = to_resources.filter(path__contains=f"/{filename.lstrip('/')}")
619623
if not codebase_resources:
620624
# If there's nothing to map on the ``to/`` do not create the package.
621625
return
622626

627+
# Ignore resources for paths in `ignored_resources` attribute
628+
if ignored_resources:
629+
for resource_path in ignored_resources:
630+
codebase_resources = codebase_resources.exclude(path__contains=f"/{resource_path.lstrip('/')}")
631+
623632
# Create the Package using .ABOUT data and assigned related codebase_resources
624633
pipes.update_or_create_package(project, package_data, codebase_resources)
625634

scanpipe/pipes/resolve.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ def resolve_about_package(input_location):
8989
if about_resource := about_data.get("about_resource"):
9090
package_data["filename"] = list(about_resource.keys())[0]
9191

92+
if ignored_resources := about_data.get("ignored_resources"):
93+
package_data["extra_data"] = {}
94+
package_data["extra_data"]["ignored_resources"] = list(ignored_resources.keys())
95+
9296
if license_expression := about_data.get("license_expression"):
9397
package_data["declared_license_expression"] = license_expression
9498

0 commit comments

Comments
 (0)