Skip to content

Commit 1e892b7

Browse files
committed
Add is_notice flag to the --classify option, issue #3822
Signed-off-by: Aayush Kumar <[email protected]>
1 parent e795bc6 commit 1e892b7

File tree

53 files changed

+687
-115
lines changed

Some content is hidden

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

53 files changed

+687
-115
lines changed

docs/source/cli-reference/help-text-options.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ The Following Help Text is displayed, i.e. This is the help text for Scancode Ve
154154
scans for key, top-level files. Key files are top-
155155
level codebase files such as COPYING, README and
156156
package manifests as reported by the --classify
157-
option "is_legal", "is_readme", "is_manifest" and
158-
"is_top_level" flags.
157+
option "is_legal", "is_readme", "is_manifest",
158+
"is_notice" and "is_top_level" flags.
159159
--tallies-with-details Compute tallies of license, copyright and other scans
160160
at the codebase level, keeping intermediate details
161161
at the file and directory level.
@@ -639,7 +639,7 @@ The Following Text is displayed, i.e. This is the available plugins for Scancode
639639
required_plugins:
640640
options:
641641
help_group: post-scan, name: tallies_key_files: --tallies-key-files
642-
help: Compute tallies for license, copyright and other scans for key, top-level files. Key files are top-level codebase files such as COPYING, README and package manifests as reported by the --classify option "is_legal", "is_readme", "is_manifest" and "is_top_level" flags.
642+
help: Compute tallies for license, copyright and other scans for key, top-level files. Key files are top-level codebase files such as COPYING, README and package manifests as reported by the --classify option "is_legal", "is_readme", "is_manifest", "is_notice" and "is_top_level" flags.
643643
doc:
644644
Compute tallies of a scan at the codebase level for only key files.
645645

@@ -669,7 +669,7 @@ The Following Text is displayed, i.e. This is the available plugins for Scancode
669669
--------------------------------------------
670670
Plugin: scancode_pre_scan:classify class: summarycode.classify_plugin:FileClassifier
671671
codebase_attributes:
672-
resource_attributes: is_legal, is_manifest, is_readme, is_top_level, is_key_file
672+
resource_attributes: is_legal, is_manifest, is_readme, is_top_level, is_key_file, is_notice
673673
sort_order: 30
674674
required_plugins:
675675
options:

docs/source/cli-reference/scan-options-post.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,7 @@ To see all plugins available via command line help, use ``--plugins``.
10181018
- "is_readme"
10191019
- "is_top_level"
10201020
- "is_key_file"
1021+
- "is_notice"
10211022

10221023
A key-file is a top-level file, that is either a legal (LICENSE/COPYING etc), manifest or a
10231024
readme file.
@@ -1087,6 +1088,7 @@ To see all plugins available via command line help, use ``--plugins``.
10871088
"is_readme": false,
10881089
"is_top_level": true,
10891090
"is_key_file": false,
1091+
"is_notice": false,
10901092
"tallies": {
10911093
"detected_license_expression": [
10921094
{

docs/source/cli-reference/scan-options-pre.rst

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Pre-Scan Options
6262
- readme
6363
- top-level
6464
- manifest
65+
- notice
6566

6667
A manifest file in computing is a file containing metadata for a group of accompanying
6768
files that are part of a set or coherent unit.
@@ -80,6 +81,7 @@ Pre-Scan Options
8081
"is_readme": true,
8182
"is_top_level": true,
8283
"is_key_file": true
84+
"is_notice": false,
8385
}
8486

8587
----

docs/source/rst_snippets/post_scan_options.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ All "Post-Scan" Options
5353
for key, top-level files, with occurrence counts.
5454
Key files are top-level codebase files such as
5555
COPYING, README and package manifests as reported
56-
by the ``--classify`` option: "is_legal",
57-
"is_readme", "is_manifest" and "is_top_level"
58-
flags.
56+
by the ``--classify`` option: "is_legal"
57+
, "is_readme", "is_manifest", "is_notice" and
58+
"is_top_level" flags.
5959

6060
Sub-Option of: ``--classify`` and ``--summary``.
6161

src/summarycode/classify.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ def get_relative_path(root_path, path):
9191
'readme',
9292
)
9393

94+
NOTICE_STARTS_ENDS = (
95+
"notice",
96+
)
9497

9598
def check_resource_name_start_and_end(resource, STARTS_ENDS):
9699
"""
@@ -111,6 +114,7 @@ def set_classification_flags(resource,
111114
_LEGAL=LEGAL_STARTS_ENDS,
112115
_MANIF=MANIFEST_ENDS,
113116
_README=README_STARTS_ENDS,
117+
_NOTICE=NOTICE_STARTS_ENDS,
114118
):
115119
"""
116120
Set classification flags on the `resource` Resource
@@ -119,8 +123,9 @@ def set_classification_flags(resource,
119123

120124
resource.is_legal = is_legal = check_resource_name_start_and_end(resource, _LEGAL)
121125
resource.is_readme = is_readme = check_resource_name_start_and_end(resource, _README)
126+
resource.is_notice = is_notice = check_resource_name_start_and_end(resource, _NOTICE)
122127
# FIXME: this will never be picked up as this is NOT available in a pre-scan plugin
123128
has_package_data = bool(getattr(resource, 'package_data', False))
124129
resource.is_manifest = is_manifest = path.endswith(_MANIF) or has_package_data
125-
resource.is_key_file = (resource.is_top_level and (is_readme or is_legal or is_manifest))
130+
resource.is_key_file = (resource.is_top_level and (is_readme or is_legal or is_manifest or is_notice))
126131
return resource

src/summarycode/classify_plugin.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ class FileClassifier(PostScanPlugin):
7575

7676
('is_key_file',
7777
Boolean(help='True if this file is "top-level" file and either a '
78-
'legal, readme or manifest file.')),
78+
'legal, notice, readme or manifest file.')),
79+
80+
('is_notice',
81+
Boolean(help='True if this file is likely a notice file')),
7982

8083
# ('is_doc',
8184
# Boolean(help='True if this file is likely a documentation file.')),

src/summarycode/tallies.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ class KeyFilesTallies(PostScanPlugin):
304304
help='Compute tallies for license, copyright and other scans for key, '
305305
'top-level files. Key files are top-level codebase files such '
306306
'as COPYING, README and package manifests as reported by the '
307-
'--classify option "is_legal", "is_readme", "is_manifest" '
307+
'--classify option "is_legal", "is_readme", "is_manifest", "is_notice" '
308308
'and "is_top_level" flags.',
309309
help_group=POST_SCAN_GROUP,
310310
required_options=['classify', 'tallies']

tests/formattedcode/data/common/manifests-expected.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,7 @@ files:
19341934
is_readme: no
19351935
is_top_level: yes
19361936
is_key_file: no
1937+
is_notice: no
19371938
detected_license_expression:
19381939
detected_license_expression_spdx:
19391940
license_detections: []
@@ -1974,6 +1975,7 @@ files:
19741975
is_readme: no
19751976
is_top_level: yes
19761977
is_key_file: no
1978+
is_notice: no
19771979
detected_license_expression:
19781980
detected_license_expression_spdx:
19791981
license_detections: []
@@ -2092,6 +2094,7 @@ files:
20922094
is_readme: no
20932095
is_top_level: no
20942096
is_key_file: no
2097+
is_notice: no
20952098
detected_license_expression: cddl-1.0
20962099
detected_license_expression_spdx: CDDL-1.0
20972100
license_detections:
@@ -2173,6 +2176,7 @@ files:
21732176
is_readme: no
21742177
is_top_level: yes
21752178
is_key_file: no
2179+
is_notice: no
21762180
detected_license_expression:
21772181
detected_license_expression_spdx:
21782182
license_detections: []
@@ -2390,6 +2394,7 @@ files:
23902394
is_readme: no
23912395
is_top_level: no
23922396
is_key_file: no
2397+
is_notice: no
23932398
detected_license_expression: apache-2.0
23942399
detected_license_expression_spdx: Apache-2.0
23952400
license_detections:
@@ -2481,6 +2486,7 @@ files:
24812486
is_readme: no
24822487
is_top_level: yes
24832488
is_key_file: no
2489+
is_notice: no
24842490
detected_license_expression:
24852491
detected_license_expression_spdx:
24862492
license_detections: []
@@ -2631,6 +2637,7 @@ files:
26312637
is_readme: no
26322638
is_top_level: no
26332639
is_key_file: no
2640+
is_notice: no
26342641
detected_license_expression: mit
26352642
detected_license_expression_spdx: MIT
26362643
license_detections:
@@ -2702,6 +2709,7 @@ files:
27022709
is_readme: no
27032710
is_top_level: yes
27042711
is_key_file: no
2712+
is_notice: no
27052713
detected_license_expression:
27062714
detected_license_expression_spdx:
27072715
license_detections: []
@@ -2935,6 +2943,7 @@ files:
29352943
is_readme: no
29362944
is_top_level: no
29372945
is_key_file: no
2946+
is_notice: no
29382947
detected_license_expression: lgpl-3.0
29392948
detected_license_expression_spdx: LGPL-3.0-only
29402949
license_detections:

0 commit comments

Comments
 (0)