Skip to content

Commit fef2408

Browse files
authored
Merge pull request #3315 from nexB/package_key_files
Add `get_top_level_resources()` to `DatafileHandler` class
2 parents a497a89 + 837426f commit fef2408

File tree

58 files changed

+6116
-1227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+6116
-1227
lines changed

CHANGELOG.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ Package detection:
6969

7070
https://github.com/nexB/scancode-toolkit/issues/3290
7171

72+
- DatafileHandlers now have a classmethod named ``get_top_level_resources()``,
73+
which is supposed to yield the top-level Resources of a Package codebase,
74+
relative to a Package manifest file. ``maven.MavenPomXmlHandler`` is the first
75+
DatafileHandler that has this method implemented.
76+
7277

7378
License detection:
7479
~~~~~~~~~~~~~~~~~~~
@@ -161,10 +166,10 @@ License detection:
161166

162167
- We can now detect licenses using custom license texts and license rules
163168
stored in a directory or packaged as a plugin for consistent reuse and deployment.
164-
169+
165170
- There is an ``--additional-directory`` option with the ``scancode-reindex-licenses``
166171
command to add the licenses from a directory.
167-
172+
168173
- There is also a ``--only-builtin`` option to use ony builtin licenses
169174
ignoring any additional license plugins.
170175

@@ -218,7 +223,7 @@ v31.2.5 - 2023-01-09
218223

219224
This is a minor fix backport release.
220225

221-
This adds license rule changes and was requested here:
226+
This adds license rule changes and was requested here:
222227
https://github.com/nexB/scancode-toolkit/issues/3310
223228
This was originally merged in #3218 and included in
224229
the latest release v32.x, and is also being backported
@@ -612,6 +617,10 @@ Changes:
612617
- `other_holders`
613618
- `other_languages`
614619

620+
- A new field ``run_order`` has been added to ``BasePlugin`` and set on all
621+
ScanCode plugins. Plugin run order and output order are now set independently
622+
of one another.
623+
615624

616625
Documentation Update
617626
~~~~~~~~~~~~~~~~~~~~~~~~

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pefile==2022.5.30
4848
pip-requirements-parser==32.0.1
4949
pkginfo2==30.0.0
5050
pluggy==1.0.0
51-
plugincode==31.0.0
51+
plugincode==32.0.0
5252
ply==3.11
5353
publicsuffix2==2.20191221
5454
pyahocorasick==2.0.0

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ install_requires =
9797
pkginfo2 >= 30.0.0
9898
pip-requirements-parser >= 32.0.1
9999
pluggy >= 1.0.0
100-
plugincode >= 31.0.0
100+
plugincode >= 32.0.0
101101
publicsuffix2
102102
pyahocorasick >= 2.0.0
103103
pygmars >= 0.7.0
@@ -165,7 +165,6 @@ console_scripts =
165165
scancode_pre_scan =
166166
ignore = scancode.plugin_ignore:ProcessIgnore
167167
facet = summarycode.facet:AddFacet
168-
classify = summarycode.classify_plugin:FileClassifier
169168

170169

171170
# scancode_scan is the entry point for scan plugins that run a scan after the
@@ -196,6 +195,7 @@ scancode_post_scan =
196195
filter-clues = cluecode.plugin_filter_clues:RedundantCluesFilter
197196
consolidate = summarycode.plugin_consolidate:Consolidator
198197
license-references = licensedcode.licenses_reference:LicenseReference
198+
classify = summarycode.classify_plugin:FileClassifier
199199

200200

201201
# scancode_output_filter is the entry point for filter plugins executed after

src/cluecode/plugin_copyright.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class CopyrightScanner(ScanPlugin):
2828
('authors', attr.ib(default=attr.Factory(list))),
2929
])
3030

31+
run_order = 6
3132
sort_order = 6
3233

3334
options = [

src/cluecode/plugin_email.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class EmailScanner(ScanPlugin):
2525
"""
2626
resource_attributes = dict(emails=attr.ib(default=attr.Factory(list)))
2727

28+
run_order = 7
2829
sort_order = 7
2930

3031
options = [

src/cluecode/plugin_filter_clues.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class RedundantCluesFilter(PostScanPlugin):
4141
Filter redundant clues (copyrights, authors, emails, and urls) that are
4242
already contained in a matched license text.
4343
"""
44+
run_order = 1
4445
sort_order = 1
4546

4647
options = [

src/cluecode/plugin_url.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class UrlScanner(ScanPlugin):
2626

2727
resource_attributes = dict(urls=attr.ib(default=attr.Factory(list)))
2828

29+
run_order = 8
2930
sort_order = 8
3031

3132
options = [

src/licensedcode/licenses_reference.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class LicenseReference(PostScanPlugin):
4848
)
4949

5050
# TODO: send to the tail of the scan, after files
51+
run_order = 1000
5152
sort_order = 1000
5253

5354
options = [

src/licensedcode/plugin_license.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class LicenseScanner(ScanPlugin):
7171
license_detections=attr.ib(default=attr.Factory(list)),
7272
)
7373

74+
run_order = 4
7475
sort_order = 4
7576

7677
options = [

src/licensedcode/plugin_license_policy.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class LicensePolicy(PostScanPlugin):
5151

5252
resource_attributes = dict(license_policy=attr.ib(default=attr.Factory(list)))
5353

54+
run_order = 9
5455
sort_order = 9
5556

5657
options = [
@@ -100,8 +101,8 @@ def process_codebase(self, codebase, license_policy, **kwargs):
100101
if key == policy.get('license_key'):
101102
# Apply the policy to the Resource
102103
license_policies.append(policy)
103-
104-
resource.license_policy = sorted(license_policies, key=lambda d: d['license_key'])
104+
105+
resource.license_policy = sorted(license_policies, key=lambda d: d['license_key'])
105106
codebase.save_resource(resource)
106107

107108

0 commit comments

Comments
 (0)