Skip to content

Commit 3ca4308

Browse files
committed
Add Post Scan Plugin --package-summary option
Signed-off-by: swastik <swastkk@gmail.com>
1 parent 7322dc2 commit 3ca4308

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ scancode_scan =
188188
# scan plugins and before the output plugins. See also plugincode.post_scan
189189
# module for details and doc.
190190
scancode_post_scan =
191+
package_summary = summarycode.package_summary:PackageSummary
191192
summary = summarycode.summarizer:ScanSummary
192193
tallies = summarycode.tallies:Tallies
193194
tallies-with-details = summarycode.tallies:TalliesWithDetails

src/summarycode/package_summary.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# ScanCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/scancode-toolkit for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#
9+
10+
from plugincode.post_scan import PostScanPlugin
11+
from plugincode.post_scan import post_scan_impl
12+
from commoncode.cliutils import PluggableCommandLineOption
13+
from commoncode.cliutils import POST_SCAN_GROUP
14+
15+
@post_scan_impl
16+
class PackageSummary(PostScanPlugin):
17+
"""
18+
Summary at the Package Level.
19+
"""
20+
21+
options = [
22+
PluggableCommandLineOption(('--package-summary',),
23+
is_flag=True, default=False,
24+
help='Generate Package Level summary',
25+
help_group=POST_SCAN_GROUP)
26+
]
27+
28+
def is_enabled(self, package_summary, **kwargs):
29+
return package_summary
30+
31+
def process_codebase(self, codebase, package_summary, **kwargs):
32+
"""
33+
Process the codebase.
34+
"""
35+
if not self.is_enabled(package_summary):
36+
return

0 commit comments

Comments
 (0)