@@ -595,7 +595,8 @@ def _f_definitions(self, functions_definitions):
595595 if self .source_code :
596596 funcs_info [f .name ]["source_code" ] = ast_to_source_code (f )
597597 if self .data_flow :
598- code_tokens , dfg = extract_dataflow (funcs_info [f .name ]["source_code" ], self .parser , "python" )
598+ temp_source_code = ast_to_source_code (f )
599+ code_tokens , dfg = extract_dataflow (temp_source_code , self .parser , "python" )
599600 funcs_info [f .name ]["data_flow" ] = dfg
600601 funcs_info [f .name ]["code_tokens" ] = code_tokens
601602 return funcs_info
@@ -1254,22 +1255,26 @@ def create_output_dirs(output_dir, control_flow):
12541255 help = "extract metadata of the target repository using Github API. (requires repository to have the .git folder)" )
12551256@click .option ('-df' , '--data_flow' , type = bool , is_flag = True ,
12561257 help = "extract data flow graph of every function in the target repository" )
1257-
12581258def main (input_path , output_dir , ignore_dir_pattern , ignore_file_pattern , requirements , html_output , call_list ,
12591259 control_flow , directory_tree , software_invocation , abstract_syntax_tree , source_code , license_detection , readme ,
12601260 metadata , data_flow , symbol_table ):
12611261 if data_flow :
1262- if symbol_table == "my_language.so" : # default option
1263- path_to_languages = str (Path (__file__ ).parent / "resources" )
1264- if sys .platform .startswith ("win" ) or sys .platform .startswith ("cygwin" ):
1265- language = Language (path_to_languages + os .path .sep + "python_win.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" )
12661271 else :
1267- language = Language (path_to_languages + os . path . sep + "python_unix.so" , "python" )
1268- else :
1269- language = Language ( symbol_table , "python" )
1270- parser = Parser ()
1271- parser . set_language ( language )
1272- 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 ))
12731278 else :
12741279 parser = []
12751280
@@ -1311,22 +1316,37 @@ def main(input_path, output_dir, ignore_dir_pattern, ignore_file_pattern, requir
13111316 except :
13121317 print ("Readme not found at root level" )
13131318 for subdir , dirs , files in os .walk (input_path ):
1314-
1319+ # print(subdir, dirs, files)
13151320 for ignore_d in ignore_dir_pattern :
13161321 dirs [:] = [d for d in dirs if not d .startswith (ignore_d )]
13171322 for ignore_f in ignore_file_pattern :
13181323 files [:] = [f for f in files if not f .startswith (ignore_f )]
13191324 for f in files :
13201325 if ".py" in f and not f .endswith (".pyc" ):
1326+ # path = os.path.join(subdir, f)
1327+ # # print(path)
1328+ # relative_path = Path(subdir).relative_to(Path(input_path).parent)
1329+ # out_dir = str(Path(output_dir) / relative_path)
1330+ # cf_dir, json_dir = create_output_dirs(out_dir, control_flow)
1331+ # code_info = CodeInspection(path, cf_dir, json_dir, control_flow, abstract_syntax_tree, source_code,
1332+ # data_flow, parser)
1333+ #
1334+ # if code_info.fileJson:
1335+ # print(code_info.fileJson[0])
1336+ # if out_dir not in dir_info:
1337+ # dir_info[out_dir] = [code_info.fileJson[0]]
1338+ # else:
1339+ # dir_info[out_dir].append(code_info.fileJson[0])
13211340 try :
1322-
13231341 path = os .path .join (subdir , f )
1342+ # print(path)
13241343 relative_path = Path (subdir ).relative_to (Path (input_path ).parent )
13251344 out_dir = str (Path (output_dir ) / relative_path )
13261345 cf_dir , json_dir = create_output_dirs (out_dir , control_flow )
13271346 code_info = CodeInspection (path , cf_dir , json_dir , control_flow , abstract_syntax_tree , source_code , data_flow , parser )
1328- # print(parsers)
1347+
13291348 if code_info .fileJson :
1349+ # print(code_info.fileJson[0])
13301350 if out_dir not in dir_info :
13311351 dir_info [out_dir ] = [code_info .fileJson [0 ]]
13321352 else :
0 commit comments