@@ -98,21 +98,21 @@ def to_dict(self, **kwargs):
9898
9999
100100@attr .s
101- class ConsolidatedPackage (object ):
102- package = attr .ib ()
101+ class ConsolidatedPackageManifest (object ):
102+ package_manifest = attr .ib ()
103103 consolidation = attr .ib ()
104104
105105 def to_dict (self , ** kwargs ):
106- package = self .package .to_dict ()
107- package .update (self .consolidation .to_dict ())
108- return package
106+ package_manifest = self .package_manifest .to_dict ()
107+ package_manifest .update (self .consolidation .to_dict ())
108+ return package_manifest
109109
110110
111111@post_scan_impl
112112class Consolidator (PostScanPlugin ):
113113 """
114114 A ScanCode post-scan plugin to return consolidated components and consolidated
115- packages for different types of codebase summarization.
115+ package_manifests 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_packages = attr .ib (default = attr .Factory (list ))
130+ consolidated_package_manifests = attr .ib (default = attr .Factory (list ))
131131 )
132132
133133 resource_attributes = dict (
@@ -140,9 +140,10 @@ 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 packages and '
143+ 'return those groupings as a list of consolidated package_manifests and '
144144 'a list of consolidated components. '
145- 'This requires the scan to have/be run with the copyright, license, and package options active' ,
145+ 'This requires the scan to have/be run with the copyright, license, and '
146+ 'package options active' ,
146147 help_group = POST_SCAN_GROUP
147148 )
148149 ]
@@ -151,12 +152,12 @@ def is_enabled(self, consolidate, **kwargs):
151152 return consolidate
152153
153154 def process_codebase (self , codebase , ** kwargs ):
154- # Collect ConsolidatedPackages and ConsolidatedComponents
155+ # Collect ConsolidatedPackageManifests and ConsolidatedComponents
155156 # TODO: Have a "catch-all" Component for the things that we haven't grouped
156157 consolidations = []
157158 root = codebase .root
158- if hasattr (root , 'packages ' ) and hasattr (root , 'copyrights' ) and hasattr (root , 'licenses' ):
159- consolidations .extend (get_consolidated_packages (codebase ))
159+ if hasattr (root , 'package_manifests ' ) and hasattr (root , 'copyrights' ) and hasattr (root , 'licenses' ):
160+ consolidations .extend (get_consolidated_package_manifests (codebase ))
160161 if hasattr (root , 'copyrights' ) and hasattr (root , 'licenses' ):
161162 consolidations .extend (get_holders_consolidated_components (codebase ))
162163
@@ -166,24 +167,24 @@ def process_codebase(self, codebase, **kwargs):
166167 # Sort consolidations by holders for consistent ordering before enumeration
167168 consolidations = sorted (consolidations , key = lambda c : '_' .join (h .key for h in c .consolidation .core_holders ))
168169
169- # Add ConsolidatedPackages and ConsolidatedComponents to top-level codebase attributes
170- codebase .attributes .consolidated_packages = consolidated_packages = []
170+ # Add ConsolidatedPackageManifests and ConsolidatedComponents to top-level codebase attributes
171+ codebase .attributes .consolidated_package_manifests = consolidated_package_manifests = []
171172 codebase .attributes .consolidated_components = consolidated_components = []
172173 identifier_counts = Counter ()
173174 for index , c in enumerate (consolidations , start = 1 ):
174175 # Skip consolidation if it does not have any Files
175176 if c .consolidation .files_count == 0 :
176177 continue
177- if isinstance (c , ConsolidatedPackage ):
178+ if isinstance (c , ConsolidatedPackageManifest ):
178179 # We use the purl as the identifier for ConsolidatedPackages
179- purl = c .package .purl
180+ purl = c .package_manifest .purl
180181 identifier_counts [purl ] += 1
181182 identifier = python_safe_name ('{}_{}' .format (purl , identifier_counts [purl ]))
182183 c .consolidation .identifier = identifier
183184 for resource in c .consolidation .resources :
184185 resource .consolidated_to .append (identifier )
185186 resource .save (codebase )
186- consolidated_packages .append (c .to_dict ())
187+ consolidated_package_manifests .append (c .to_dict ())
187188 elif isinstance (c , ConsolidatedComponent ):
188189 consolidation_identifier = c .consolidation .identifier
189190 if consolidation_identifier :
@@ -218,20 +219,20 @@ def process_codebase(self, codebase, **kwargs):
218219 resource .save (codebase )
219220
220221
221- def get_consolidated_packages (codebase ):
222+ def get_consolidated_package_manifests (codebase ):
222223 """
223- Yield a ConsolidatedPackage for each detected package in the codebase
224+ Yield a ConsolidatedPackageManifest for each detected package_manifest in the codebase
224225 """
225226 for resource in codebase .walk (topdown = False ):
226- for package_data in resource .packages :
227- package = get_package_instance (package_data )
228- package_root = package .get_package_root (resource , codebase )
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 )
229230 package_root .extra_data ['package_root' ] = True
230231 package_root .save (codebase )
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
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
235236
236237 package_holders = []
237238 if package_copyright :
@@ -273,14 +274,14 @@ def get_consolidated_packages(codebase):
273274 resources = package_resources ,
274275 )
275276 if is_build_file :
276- c .identifier = package .name
277+ c .identifier = package_manifest .name
277278 yield ConsolidatedComponent (
278279 type = 'build' ,
279280 consolidation = c
280281 )
281282 else :
282- yield ConsolidatedPackage (
283- package = package ,
283+ yield ConsolidatedPackageManifest (
284+ package_manifest = package_manifest ,
284285 consolidation = c
285286 )
286287
0 commit comments