Skip to content

Commit ed891cf

Browse files
committed
fixed the errors when header is absent
Signed-off-by: Srthkdb <[email protected]>
1 parent db03ed1 commit ed891cf

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/attributecode/transform.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,15 @@ def transform_json(data, transformer):
128128
new_data = []
129129
renamings = transformer.column_renamings
130130
#if json is output of scancode-toolkit
131-
if(data["headers"][0]["tool_name"] == "scancode-toolkit"):
132-
#only takes data inside "files"
133-
data = data["files"]
134-
#automatically renames path to about_resource
135-
if("path" not in renamings.keys()):
136-
renamings["path"] = "about_resource"
137-
131+
try:
132+
if(data["headers"][0]["tool_name"] == "scancode-toolkit"):
133+
#only takes data inside "files"
134+
data = data["files"]
135+
#automatically renames path to about_resource
136+
if("path" not in renamings.keys()):
137+
renamings["path"] = "about_resource"
138+
except:
139+
pass
138140
if isinstance(data, list):
139141
for item in data:
140142
element, err = process_json_keys(item, renamings, transformer)

tests/testdata/test_transform/configuration_scancode

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ column_filters:
66
- about_resource
77
required_columns:
88
- name
9-
- type
109

1110

0 commit comments

Comments
 (0)