Skip to content

Commit

Permalink
Merge remote-tracking branch 'JRavi2/rename-first-column-in-csv' into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
pombredanne committed Jan 8, 2022
2 parents 37d574b + f9cbf75 commit d9ba058
Show file tree
Hide file tree
Showing 13 changed files with 307 additions and 307 deletions.
18 changes: 9 additions & 9 deletions src/formattedcode/output_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def collect_keys(mapping, key_group):

errors = scanned_file.pop('scan_errors', [])

file_info = dict(Resource=path)
file_info = dict(path=path)
file_info.update(((k, v) for k, v in scanned_file.items()
# FIXME: info are NOT lists: lists are the actual scans
if not isinstance(v, (list, dict))))
Expand All @@ -124,12 +124,12 @@ def collect_keys(mapping, key_group):
yield file_info

for lic_exp in scanned_file.get('license_expressions', []):
inf = dict(Resource=path, license_expression=lic_exp)
inf = dict(path=path, license_expression=lic_exp)
collect_keys(inf, 'license_expression')
yield inf

for licensing in scanned_file.get('licenses', []):
lic = dict(Resource=path)
lic = dict(path=path)
for k, val in licensing.items():
# do not include matched text for now.
if k == 'matched_text':
Expand Down Expand Up @@ -159,37 +159,37 @@ def collect_keys(mapping, key_group):
yield lic

for copyr in scanned_file.get('copyrights', []):
inf = dict(Resource=path)
inf = dict(path=path)
inf['copyright'] = copyr['value']
inf['start_line'] = copyr['start_line']
inf['end_line'] = copyr['start_line']
collect_keys(inf, 'copyright')
yield inf

for copyr in scanned_file.get('holders', []):
inf = dict(Resource=path)
inf = dict(path=path)
inf['copyright_holder'] = copyr['value']
inf['start_line'] = copyr['start_line']
inf['end_line'] = copyr['start_line']
collect_keys(inf, 'copyright')
yield inf

for copyr in scanned_file.get('authors', []):
inf = dict(Resource=path)
inf = dict(path=path)
inf['author'] = copyr['value']
inf['start_line'] = copyr['start_line']
inf['end_line'] = copyr['start_line']
collect_keys(inf, 'copyright')
yield inf

for email in scanned_file.get('emails', []):
email_info = dict(Resource=path)
email_info = dict(path=path)
email_info.update(email)
collect_keys(email_info, 'email')
yield email_info

for url in scanned_file.get('urls', []):
url_info = dict(Resource=path)
url_info = dict(path=path)
url_info.update(url)
collect_keys(url_info, 'url')
yield url_info
Expand Down Expand Up @@ -263,7 +263,7 @@ def flatten_package(_package, path, prefix='package__'):

package_columns = get_package_columns()

pack = dict(Resource=path)
pack = dict(path=path)
for k, val in _package.items():
if k not in package_columns:
continue
Expand Down
8 changes: 4 additions & 4 deletions tests/formattedcode/data/csv/expressions/expected.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Resource,type,scan_errors,license_expression
apache-2.0.LICENSE,file,,
apache-2.0.LICENSE,,,apache-2.0
apache-2.0.LICENSE,,,mit
path,type,scan_errors,license_expression
apache-2.0.LICENSE,file,,
apache-2.0.LICENSE,,,apache-2.0
apache-2.0.LICENSE,,,mit
Loading

0 comments on commit d9ba058

Please sign in to comment.