Merge pull request #2962 from garenchan/dev

Cache return values to avoid repeated function calls.
This commit is contained in:
David Lord 2018-10-23 08:27:46 -07:00 committed by GitHub
commit 70b45094ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -206,8 +206,9 @@ def prepare_import(path):
"""
path = os.path.realpath(path)
if os.path.splitext(path)[1] == '.py':
path = os.path.splitext(path)[0]
fname, ext = os.path.splitext(path)
if ext == '.py':
path = fname
if os.path.basename(path) == '__init__':
path = os.path.dirname(path)