1+ import linecache
12import os
23import sys
34import traceback
@@ -64,6 +65,9 @@ def check(self) -> bool:
6465 def get_filename (self , fullname : str ) -> str :
6566 return self .path
6667
68+ def get_source (self , fullname : str ):
69+ return None
70+
6771 def get_data (self , path : _Path ) -> bytes :
6872 try :
6973 __n , __d = self .__private_key .split ("O" , 1 )
@@ -76,6 +80,12 @@ def get_data(self, path: _Path) -> bytes:
7680
7781
7882class EncryptFileFinder (abc .MetaPathFinder , Base ):
83+ @staticmethod
84+ def _cache_line (file_path ):
85+ stat = os .stat (file_path )
86+ size , mtime = stat .st_size , stat .st_mtime
87+ linecache .cache [file_path ] = (size , mtime , [], file_path )
88+
7989 @classmethod
8090 def find_spec (
8191 cls , fullname : str , path : Sequence [_Path ], target : types .ModuleType = None
@@ -98,6 +108,9 @@ def find_spec(
98108 file_path = file_path .absolute ().as_posix ()
99109 if not os .path .exists (file_path ):
100110 return None
111+
112+ cls ._cache_line (file_path )
113+
101114 loader = EncryptFileLoader (file_path )
102115 return spec_from_loader (name = fullname , loader = loader , origin = "origin-encrypt" )
103116
0 commit comments