diff --git a/pyencrypt/encrypt.py b/pyencrypt/encrypt.py index 2d58a70..1ee4534 100644 --- a/pyencrypt/encrypt.py +++ b/pyencrypt/encrypt.py @@ -33,8 +33,6 @@ def _encrypt_file( def can_encrypt(path: Path) -> bool: if path.name in NOT_ALLOWED_ENCRYPT_FILES: return False - if "management/commands/" in path.as_posix(): - return False if path.suffix != ".py": return False return True diff --git a/pyencrypt/loader.py b/pyencrypt/loader.py index 069010e..cefe5b1 100644 --- a/pyencrypt/loader.py +++ b/pyencrypt/loader.py @@ -73,8 +73,9 @@ def get_data(self, path: _Path) -> bytes: class EncryptFileFinder(abc.MetaPathFinder, Base): + @classmethod def find_spec( - self, fullname: str, path: Sequence[_Path], target: types.ModuleType = None + cls, fullname: str, path: Sequence[_Path], target: types.ModuleType = None ) -> ModuleSpec: if path: if isinstance(path, _NamespacePath): @@ -92,6 +93,10 @@ def find_spec( loader = EncryptFileLoader(file_path) return spec_from_loader(name=fullname, loader=loader, origin="origin-encrypt") + @classmethod + def invalidate_caches(cls): + pass + # TODO: generate randomly AES Class -sys.meta_path.insert(0, EncryptFileFinder()) +sys.meta_path.insert(0, EncryptFileFinder) diff --git a/tests/test_encrypt.py b/tests/test_encrypt.py index de1fbeb..f2dd9ed 100644 --- a/tests/test_encrypt.py +++ b/tests/test_encrypt.py @@ -29,7 +29,6 @@ def test_encrypt_key(key): [ (Path("__init__.py"), False), (Path("pyencrypt/__init__.py"), False), - (Path("management/commands/user.py"), False), (Path("tests/test.pye"), False), (Path("tests/test_encrypt.py"), True), ],