Skip to content

Commit

Permalink
perf: ⚡️ Finder file_path
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoQi99 committed Nov 6, 2024
1 parent 9433e92 commit ef1d328
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pyencrypt/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit ef1d328

Please sign in to comment.