Skip to content

Commit 71739bf

Browse files
committed
fixing remaining test and robustness of the app
1 parent c70ee89 commit 71739bf

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

inspect4py/cli.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,24 +1255,26 @@ def create_output_dirs(output_dir, control_flow):
12551255
help="extract metadata of the target repository using Github API. (requires repository to have the .git folder)")
12561256
@click.option('-df', '--data_flow', type=bool, is_flag=True,
12571257
help="extract data flow graph of every function in the target repository")
1258-
12591258
def main(input_path, output_dir, ignore_dir_pattern, ignore_file_pattern, requirements, html_output, call_list,
12601259
control_flow, directory_tree, software_invocation, abstract_syntax_tree, source_code, license_detection, readme,
12611260
metadata, data_flow, symbol_table):
12621261
if data_flow:
1263-
if symbol_table == "my_language.so": # default option
1264-
path_to_languages = str(Path(__file__).parent / "resources")
1265-
if sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
1266-
language = Language(path_to_languages + os.path.sep + "python_win.so", "python")
1267-
elif sys.platform.startswith("darwin"):
1268-
language = Language(path_to_languages + os.path.sep + "python_mac.so", "python")
1262+
try:
1263+
if symbol_table == "my_language.so": # default option
1264+
path_to_languages = str(Path(__file__).parent / "resources")
1265+
if sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
1266+
language = Language(path_to_languages + os.path.sep + "python_win.so", "python")
1267+
elif sys.platform.startswith("darwin"):
1268+
language = Language(path_to_languages + os.path.sep + "python_mac.so", "python")
1269+
else:
1270+
language = Language(path_to_languages + os.path.sep + "python_unix.so", "python")
12691271
else:
1270-
language = Language(path_to_languages + os.path.sep + "python_unix.so", "python")
1271-
else:
1272-
language = Language(symbol_table, "python")
1273-
parser = Parser()
1274-
parser.set_language(language)
1275-
parser = [parser, DFG_python]
1272+
language = Language(symbol_table, "python")
1273+
parser = Parser()
1274+
parser.set_language(language)
1275+
parser = [parser, DFG_python]
1276+
except Exception as e:
1277+
print("Problem loading language file " + str(e))
12761278
else:
12771279
parser = []
12781280

test/test_inspect4py.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,9 @@ def test_data_flow(self):
486486
path_to_languages = str(Path(__file__).parent.parent / "inspect4py" / "resources")
487487
if sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
488488
language = Language(path_to_languages + os.path.sep + "python_win.so", "python")
489-
else: # mac and unix should be compatible
489+
elif sys.platform.startswith("darwin"):
490+
language = Language(path_to_languages + os.path.sep + "python_mac.so", "python")
491+
else: # unix should be compatible
490492
language = Language(path_to_languages + os.path.sep + "python_unix.so", "python")
491493
parser = Parser()
492494
parser.set_language(language)

0 commit comments

Comments
 (0)