Skip to content

Commit a9f7ed3

Browse files
committed
Add is_notice flag to the --classify option, issue #3822
Signed-off-by: Aayush Kumar <aayush214.kumar@gmail.com>
1 parent e795bc6 commit a9f7ed3

16 files changed

+46
-2
lines changed

src/summarycode/classify.py

Lines changed: 6 additions & 1 deletion
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

Lines changed: 4 additions & 1 deletion
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.')),

tests/summarycode/data/classify/cli.expected.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"is_readme": false,
2525
"is_top_level": true,
2626
"is_key_file": false,
27+
"is_notice": false,
2728
"files_count": 8,
2829
"dirs_count": 1,
2930
"size_count": 0,
@@ -53,6 +54,7 @@
5354
"is_readme": true,
5455
"is_top_level": true,
5556
"is_key_file": true,
57+
"is_notice": false,
5658
"files_count": 0,
5759
"dirs_count": 0,
5860
"size_count": 0,
@@ -82,6 +84,7 @@
8284
"is_readme": true,
8385
"is_top_level": true,
8486
"is_key_file": true,
87+
"is_notice": false,
8588
"files_count": 0,
8689
"dirs_count": 0,
8790
"size_count": 0,
@@ -111,6 +114,7 @@
111114
"is_readme": false,
112115
"is_top_level": true,
113116
"is_key_file": true,
117+
"is_notice": false,
114118
"files_count": 0,
115119
"dirs_count": 0,
116120
"size_count": 0,
@@ -140,6 +144,7 @@
140144
"is_readme": false,
141145
"is_top_level": true,
142146
"is_key_file": true,
147+
"is_notice": false,
143148
"files_count": 0,
144149
"dirs_count": 0,
145150
"size_count": 0,
@@ -169,6 +174,7 @@
169174
"is_readme": false,
170175
"is_top_level": true,
171176
"is_key_file": false,
177+
"is_notice": false,
172178
"files_count": 2,
173179
"dirs_count": 0,
174180
"size_count": 0,
@@ -198,6 +204,7 @@
198204
"is_readme": false,
199205
"is_top_level": false,
200206
"is_key_file": false,
207+
"is_notice": false,
201208
"files_count": 0,
202209
"dirs_count": 0,
203210
"size_count": 0,
@@ -227,6 +234,7 @@
227234
"is_readme": false,
228235
"is_top_level": false,
229236
"is_key_file": false,
237+
"is_notice": false,
230238
"files_count": 0,
231239
"dirs_count": 0,
232240
"size_count": 0,
@@ -256,6 +264,7 @@
256264
"is_readme": false,
257265
"is_top_level": true,
258266
"is_key_file": false,
267+
"is_notice": false,
259268
"files_count": 0,
260269
"dirs_count": 0,
261270
"size_count": 0,
@@ -285,6 +294,7 @@
285294
"is_readme": false,
286295
"is_top_level": true,
287296
"is_key_file": false,
297+
"is_notice": false,
288298
"files_count": 0,
289299
"dirs_count": 0,
290300
"size_count": 0,

tests/summarycode/data/classify/notice/ATTRIBUTION_NOTICE.txt

Whitespace-only changes.

tests/summarycode/data/classify/notice/LICENSE-NOTICE.txt

Whitespace-only changes.

tests/summarycode/data/classify/notice/NOTICE

Whitespace-only changes.

tests/summarycode/data/classify/notice/NOTICE-APACHE.txt

Whitespace-only changes.

tests/summarycode/data/classify/notice/NOTICE-LEGAL.TXT

Whitespace-only changes.

tests/summarycode/data/classify/notice/NOTICE-LEGAL.txt

Whitespace-only changes.

tests/summarycode/data/classify/notice/NOTICE-README.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)