@@ -98,21 +98,21 @@ def to_dict(self, **kwargs):
9898
9999
100100@attr .s
101- class ConsolidatedPackageManifest (object ):
102- package_manifest = attr .ib ()
101+ class ConsolidatedPackage (object ):
102+ package = attr .ib ()
103103 consolidation = attr .ib ()
104104
105105 def to_dict (self , ** kwargs ):
106- package_manifest = self .package_manifest .to_dict ()
107- package_manifest .update (self .consolidation .to_dict ())
108- return package_manifest
106+ package = self .package .to_dict ()
107+ package .update (self .consolidation .to_dict ())
108+ return package
109109
110110
111111@post_scan_impl
112112class Consolidator (PostScanPlugin ):
113113 """
114114 A ScanCode post-scan plugin to return consolidated components and consolidated
115- package_manifests for different types of codebase summarization.
115+ packages for different types of codebase summarization.
116116
117117 A consolidated component is a group of Resources that have the same origin.
118118 Currently, a ConsolidatedComponent is created for each detected copyright holder
@@ -127,7 +127,7 @@ class Consolidator(PostScanPlugin):
127127 """
128128 codebase_attributes = dict (
129129 consolidated_components = attr .ib (default = attr .Factory (list )),
130- consolidated_package_manifests = attr .ib (default = attr .Factory (list ))
130+ consolidated_packages = attr .ib (default = attr .Factory (list ))
131131 )
132132
133133 resource_attributes = dict (
@@ -140,10 +140,9 @@ class Consolidator(PostScanPlugin):
140140 PluggableCommandLineOption (('--consolidate' ,),
141141 is_flag = True , default = False ,
142142 help = 'Group resources by Packages or license and copyright holder and '
143- 'return those groupings as a list of consolidated package_manifests and '
143+ 'return those groupings as a list of consolidated packages and '
144144 'a list of consolidated components. '
145- 'This requires the scan to have/be run with the copyright, license, and '
146- 'package options active' ,
145+ 'This requires the scan to have/be run with the copyright, license, and package options active' ,
147146 help_group = POST_SCAN_GROUP
148147 )
149148 ]
@@ -152,12 +151,12 @@ def is_enabled(self, consolidate, **kwargs):
152151 return consolidate
153152
154153 def process_codebase (self , codebase , ** kwargs ):
155- # Collect ConsolidatedPackageManifests and ConsolidatedComponents
154+ # Collect ConsolidatedPackages and ConsolidatedComponents
156155 # TODO: Have a "catch-all" Component for the things that we haven't grouped
157156 consolidations = []
158157 root = codebase .root
159- if hasattr (root , 'package_manifests ' ) and hasattr (root , 'copyrights' ) and hasattr (root , 'licenses' ):
160- consolidations .extend (get_consolidated_package_manifests (codebase ))
158+ if hasattr (root , 'packages ' ) and hasattr (root , 'copyrights' ) and hasattr (root , 'licenses' ):
159+ consolidations .extend (get_consolidated_packages (codebase ))
161160 if hasattr (root , 'copyrights' ) and hasattr (root , 'licenses' ):
162161 consolidations .extend (get_holders_consolidated_components (codebase ))
163162
@@ -167,24 +166,24 @@ def process_codebase(self, codebase, **kwargs):
167166 # Sort consolidations by holders for consistent ordering before enumeration
168167 consolidations = sorted (consolidations , key = lambda c : '_' .join (h .key for h in c .consolidation .core_holders ))
169168
170- # Add ConsolidatedPackageManifests and ConsolidatedComponents to top-level codebase attributes
171- codebase .attributes .consolidated_package_manifests = consolidated_package_manifests = []
169+ # Add ConsolidatedPackages and ConsolidatedComponents to top-level codebase attributes
170+ codebase .attributes .consolidated_packages = consolidated_packages = []
172171 codebase .attributes .consolidated_components = consolidated_components = []
173172 identifier_counts = Counter ()
174173 for index , c in enumerate (consolidations , start = 1 ):
175174 # Skip consolidation if it does not have any Files
176175 if c .consolidation .files_count == 0 :
177176 continue
178- if isinstance (c , ConsolidatedPackageManifest ):
177+ if isinstance (c , ConsolidatedPackage ):
179178 # We use the purl as the identifier for ConsolidatedPackages
180- purl = c .package_manifest .purl
179+ purl = c .package .purl
181180 identifier_counts [purl ] += 1
182181 identifier = python_safe_name ('{}_{}' .format (purl , identifier_counts [purl ]))
183182 c .consolidation .identifier = identifier
184183 for resource in c .consolidation .resources :
185184 resource .consolidated_to .append (identifier )
186185 resource .save (codebase )
187- consolidated_package_manifests .append (c .to_dict ())
186+ consolidated_packages .append (c .to_dict ())
188187 elif isinstance (c , ConsolidatedComponent ):
189188 consolidation_identifier = c .consolidation .identifier
190189 if consolidation_identifier :
@@ -219,20 +218,20 @@ def process_codebase(self, codebase, **kwargs):
219218 resource .save (codebase )
220219
221220
222- def get_consolidated_package_manifests (codebase ):
221+ def get_consolidated_packages (codebase ):
223222 """
224- Yield a ConsolidatedPackageManifest for each detected package_manifest in the codebase
223+ Yield a ConsolidatedPackage for each detected package in the codebase
225224 """
226225 for resource in codebase .walk (topdown = False ):
227- for package_manifest_data in resource .package_manifests :
228- package_manifest = get_package_instance (package_manifest_data )
229- package_root = package_manifest .get_package_root (resource , codebase )
226+ for package_data in resource .packages :
227+ package = get_package_instance (package_data )
228+ package_root = package .get_package_root (resource , codebase )
230229 package_root .extra_data ['package_root' ] = True
231230 package_root .save (codebase )
232- is_build_file = isinstance (package_manifest , BaseBuildManifestPackage )
233- package_resources = list (package_manifest .get_package_resources (package_root , codebase ))
234- package_license_expression = package_manifest .license_expression
235- package_copyright = package_manifest .copyright
231+ is_build_file = isinstance (package , BaseBuildManifestPackage )
232+ package_resources = list (package .get_package_resources (package_root , codebase ))
233+ package_license_expression = package .license_expression
234+ package_copyright = package .copyright
236235
237236 package_holders = []
238237 if package_copyright :
@@ -274,14 +273,14 @@ def get_consolidated_package_manifests(codebase):
274273 resources = package_resources ,
275274 )
276275 if is_build_file :
277- c .identifier = package_manifest .name
276+ c .identifier = package .name
278277 yield ConsolidatedComponent (
279278 type = 'build' ,
280279 consolidation = c
281280 )
282281 else :
283- yield ConsolidatedPackageManifest (
284- package_manifest = package_manifest ,
282+ yield ConsolidatedPackage (
283+ package = package ,
285284 consolidation = c
286285 )
287286
0 commit comments