@@ -12,33 +12,30 @@ def test_linkage(self):
1212 rf = runfiles .Create ()
1313 d = rf .Rlocation ("_main/tests/cc/current_py_cc_headers" )
1414 d = pathlib .Path (d )
15- for f in d .glob ("*.dll" ):
16- print (f )
17-
18- d = rf .Rlocation ("_main/tests/cc/current_py_cc_headers" )
19- print (f"[*] Analyzing dependencies for: { file_path } \n " )
20-
21- try :
22- # Parse the PE file
23- pe = pefile .PE (file_path )
24-
25- if not hasattr (pe , 'DIRECTORY_ENTRY_IMPORT' ):
26- print ("[!] No import directory found. The file may not have dependencies or is packed." )
27- raise Exception ("no deps?" )
28-
29- print ("Imported DLLs:" )
30-
31- # Iterate over the import directory entries
32- # Each 'entry' corresponds to one imported DLL
33- for entry in pe .DIRECTORY_ENTRY_IMPORT :
34- # entry.dll is a bytes string, so we decode it to utf-8
35- dll_name = entry .dll .decode ('utf-8' )
36- print (f" - { dll_name } " )
37-
38- except pefile .PEFormatError as e :
39- print (f"Error: Not a valid PE file (DLL/EXE). \n Details: { e } " )
40- except Exception as e :
41- print (f"An unexpected error occurred: { e } " )
15+ for file_path in d .glob ("*.dll" ):
16+ print (f"[*] Analyzing dependencies for: { file_path } \n " )
17+
18+ try :
19+ # Parse the PE file
20+ pe = pefile .PE (file_path )
21+
22+ if not hasattr (pe , 'DIRECTORY_ENTRY_IMPORT' ):
23+ print ("[!] No import directory found. The file may not have dependencies or is packed." )
24+ raise Exception ("no deps?" )
25+
26+ print ("Imported DLLs:" )
27+
28+ # Iterate over the import directory entries
29+ # Each 'entry' corresponds to one imported DLL
30+ for entry in pe .DIRECTORY_ENTRY_IMPORT :
31+ # entry.dll is a bytes string, so we decode it to utf-8
32+ dll_name = entry .dll .decode ('utf-8' )
33+ print (f" - { dll_name } " )
34+
35+ except pefile .PEFormatError as e :
36+ print (f"Error: Not a valid PE file (DLL/EXE). \n Details: { e } " )
37+ except Exception as e :
38+ print (f"An unexpected error occurred: { e } " )
4239
4340 raise Exception ("done" )
4441
0 commit comments