From 6ed1f0cee5ed830318e5c00db0cb99e07895d46b Mon Sep 17 00:00:00 2001 From: Nisha K Date: Thu, 28 May 2020 10:42:14 -0700 Subject: [PATCH] extensions: scancode: Fix file type reporting The get_file_type function assumed that the json object's boolean values were strings but they were in fact boolean. This change updates the function to do boolean checks on the various file type keys. Signed-off-by: Nisha K --- tern/extensions/scancode/executor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tern/extensions/scancode/executor.py b/tern/extensions/scancode/executor.py index 7cfa3a33..e11d1a80 100644 --- a/tern/extensions/scancode/executor.py +++ b/tern/extensions/scancode/executor.py @@ -34,13 +34,13 @@ def get_file_type(scancode_file_dict): '''Scancode's file dictionary has a set of keys: is_binary, is_text, is_archive, is_media, is_source, is_script using this set, return a filetype recognized by SPDX''' - if scancode_file_dict['is_binary'] == 'true': + if scancode_file_dict.get('is_binary'): return 'BINARY' - if scancode_file_dict['is_source'] == 'true': + if scancode_file_dict.get('is_source'): return 'SOURCE' - if scancode_file_dict['is_text'] == 'true': + if scancode_file_dict.get('is_text'): return 'TEXT' - if scancode_file_dict['is_archive'] == 'true': + if scancode_file_dict.get('is_archive'): return 'ARCHIVE' return 'OTHER'