From e4cebe5bce0264374d17a4f47c790d012e6e30b5 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 0d87a2c..eeb99f5 100644 --- a/pyencrypt/loader.py +++ b/pyencrypt/loader.py @@ -91,15 +91,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}"