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())
| 254 | |
| 255 | |
| 256 | def 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 | |
| 296 | def flatten_package(_package, path, prefix='package__'): |