Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename first column of csv output to "path" #2016

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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