Skip to content

Commit 0c93d6d

Browse files
committed
update: Package model to have license_clarity_score
Signed-off-by: swastik <swastkk@gmail.com>
1 parent 64957ec commit 0c93d6d

File tree

4 files changed

+41
-42
lines changed

4 files changed

+41
-42
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +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
191+
package_summary = packagedcode.plugin_package:PackageSummary
192192
summary = summarycode.summarizer:ScanSummary
193193
tallies = summarycode.tallies:Tallies
194194
tallies-with-details = summarycode.tallies:TalliesWithDetails

src/packagedcode/models.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ class Package(PackageData):
15311531
help='List of the datasource ids used to create this package.'
15321532
)
15331533

1534-
license_clarity = List(
1534+
license_clarity_score = List(
15351535
item_type=dict,
15361536
label='License Clarity Information',
15371537
help='List containing the license clarity score and related elements.'
@@ -1541,15 +1541,17 @@ def __attrs_post_init__(self, *args, **kwargs):
15411541
if not self.package_uid:
15421542
self.package_uid = build_package_uid(self.purl)
15431543

1544-
def to_dict(self):
1545-
return super().to_dict(with_details=False)
1544+
def to_dict(self, package_summary= False):
1545+
data = super().to_dict(with_details=False)
1546+
if not package_summary:
1547+
data.pop("license_clarity_score")
1548+
return data
15461549

15471550
def to_package_data(self):
15481551
mapping = super().to_dict(with_details=True)
15491552
mapping.pop('package_uid', None)
15501553
mapping.pop('datafile_paths', None)
15511554
mapping.pop('datasource_ids', None)
1552-
mapping.pop('license_clarity', None)
15531555
return PackageData.from_dict(mapping)
15541556

15551557
@classmethod

src/packagedcode/plugin_package.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616

1717
from commoncode.cliutils import PluggableCommandLineOption
1818
from commoncode.cliutils import DOC_GROUP
19-
from commoncode.cliutils import SCAN_GROUP
19+
from commoncode.cliutils import SCAN_GROUP, POST_SCAN_GROUP
2020
from commoncode.resource import Resource
2121
from commoncode.resource import strip_first_path_segment
2222
from plugincode.scan import scan_impl
23+
from plugincode.post_scan import post_scan_impl
2324
from plugincode.scan import ScanPlugin
25+
from plugincode.post_scan import PostScanPlugin
2426

2527
from licensedcode.cache import build_spdx_license_expression
2628
from licensedcode.cache import get_cache
@@ -182,6 +184,13 @@ class PackageScanner(ScanPlugin):
182184
help='Show the list of supported package manifest parsers and exit.',
183185
help_group=DOC_GROUP,
184186
),
187+
PluggableCommandLineOption(
188+
('--package-summary',),
189+
is_flag=True,
190+
default=False,
191+
help='Generate Package Level summary',
192+
help_group=POST_SCAN_GROUP,
193+
),
185194
]
186195

187196
def is_enabled(self, package, system_package, package_only, **kwargs):
@@ -272,6 +281,30 @@ def process_codebase(self, codebase, strip_root=False, package_only=False, **kwa
272281
if TRACE_LICENSE and modified:
273282
logger_debug(f'packagedcode: process_codebase: add_referenced_license_matches_from_package: modified: {modified}')
274283

284+
@post_scan_impl
285+
class PackageSummary(PostScanPlugin):
286+
"""
287+
Summary at the Package Level.
288+
"""
289+
run_order = 8
290+
sort_order= 8
291+
292+
options = [
293+
PluggableCommandLineOption(('--package-summary',),
294+
is_flag=True, default=False,
295+
help='Generate Package Level summary',
296+
help_group=POST_SCAN_GROUP)
297+
]
298+
299+
def is_enabled(self, package_summary, **kwargs):
300+
return package_summary
301+
302+
def process_codebase(self, codebase, package_summary, **kwargs):
303+
"""
304+
Process the codebase.
305+
"""
306+
if not self.is_enabled(package_summary):
307+
return
275308

276309
def add_license_from_file(resource, codebase):
277310
"""

src/summarycode/package_summary.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)