Skip to content

Commit 2ba8cd5

Browse files
dnicholdnichol
authored andcommitted
Remove file path column, remove duplicate components from components report
1 parent f2fbad0 commit 2ba8cd5

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

examples/client/file_hierarchy_report.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,22 +170,28 @@ def trim_version_report(version_report, reduced_path_set):
170170
171171
'''
172172
def get_csv_fieldnames():
173-
return ['component name', 'version name', 'license', 'file path', 'match type', 'review status']
173+
return ['component name', 'version name', 'license', 'match type', 'review status']
174174

175175
def get_csv_data(version_report):
176176
csv_data = list()
177+
components = list()
177178
for bom_view_entry in version_report['aggregateBomViewEntries']:
178-
entry = dict()
179+
entry = dict()
179180
entry['component name'] = bom_view_entry['producerProject']['name']
180181
entry['version name'] = bom_view_entry['producerReleases'][0]['version']
181182
entry['license'] = bom_view_entry['licenses'][0]['licenseDisplay'].replace(' AND ',';').replace('(','').replace(')','')
182183
pid = bom_view_entry['producerProject']['id']
183184
vid = bom_view_entry['producerReleases'][0]['id']
184-
path_list = [p['path'] for p in version_report['detailedFileBomViewEntries'] if p['projectId'] == pid and p['versionId'] == vid]
185-
entry['file path'] = ';'.join(path_list)
185+
#path_list = [p['path'] for p in version_report['detailedFileBomViewEntries'] if p['projectId'] == pid and p['versionId'] == vid]
186+
#entry['file path'] = ';'.join(path_list)
186187
entry['match type'] = ';'.join(bom_view_entry['matchTypes'])
187188
entry['review status'] = bom_view_entry['reviewSummary']['reviewStatus']
188-
csv_data.append(entry)
189+
190+
# Only add if this component was not previously added.
191+
composite_key = pid + vid
192+
if composite_key not in components:
193+
csv_data.append(entry)
194+
components.append(composite_key)
189195
return csv_data
190196

191197
def write_output_file(version_report, output_file):

0 commit comments

Comments
 (0)