MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / get_package_columns

Function get_package_columns

src/formattedcode/output_csv.py:256–293  ·  view source on GitHub ↗

Return (and cache in_columns) a set of package column names included in the CSV output. Some columsn are excluded for now such as lists of mappings: these do not serialize well to CSV

(_columns=set())

Source from the content-addressed store, hash-verified

254
255
256def get_package_columns(_columns=set()):
257 """
258 Return (and cache in_columns) a set of package column names included in the
259 CSV output.
260 Some columsn are excluded for now such as lists of mappings: these do not
261 serialize well to CSV
262 """
263 if _columns:
264 return _columns
265
266 from packagedcode.models import PackageData
267
268 package_data_fields = [field.name for field in attr.fields(PackageData)]
269
270 # exclude some columns for now that contain list of items
271 excluded_columns = {
272 # list of strings
273 'keywords',
274 # list of dicts
275 'parties',
276 'dependencies',
277 'source_packages',
278 }
279
280 # some extra columns for components
281 extra_columns = [
282 'purl',
283 'components',
284 'owner_name',
285 'reference_notes',
286 'description',
287 'notice_filename',
288 'notice_url',
289 ]
290
291 fields = package_data_fields + extra_columns
292 _columns = set(f for f in fields if f not in excluded_columns)
293 return _columns
294
295
296def flatten_package(_package, path, prefix='package__'):

Callers 1

flatten_packageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected