From ef1d328419d024b24161b907271c9c09f7f4c79e Mon Sep 17 00:00:00 2001 From: Qi Zhao Date: Wed, 6 Nov 2024 17:13:55 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E2=9A=A1=EF=B8=8F=20Finder=20file=5Fpa?= =?UTF-8?q?th?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyencrypt/loader.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pyencrypt/loader.py b/pyencrypt/loader.py index a4f6bc2..acf37c2 100644 --- a/pyencrypt/loader.py +++ b/pyencrypt/loader.py @@ -81,15 +81,11 @@ def find_spec( cls, fullname: str, path: Sequence[_Path], target: types.ModuleType = None ) -> ModuleSpec: if path: + filename = "{}{}".format(fullname.rsplit(".", 1)[-1], ENCRYPT_SUFFIX) if isinstance(path, _NamespacePath): - file_path = ( - Path(path._path[0]) - / f'{fullname.rsplit(".", 1)[-1]}{ENCRYPT_SUFFIX}' - ) + file_path = Path(path._path[0]) / filename else: - file_path = ( - Path(path[0]) / f'{fullname.rsplit(".", 1)[-1]}{ENCRYPT_SUFFIX}' - ) + file_path = Path(path[0]) / filename else: for p in sys.path: file_path = Path(p) / f"{fullname}{ENCRYPT_SUFFIX}"