From 339d2878b4a6044c3d35c51242da2dffaeb66dff Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 19 Dec 2018 19:09:48 -0500 Subject: [PATCH] Add path parent option to module path and default to using local path --- core/__init__.py | 2 +- libs/util.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 278a16fe..8f8e19fc 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -23,7 +23,7 @@ except ImportError: if sys.platform == 'win32': sys.ext('Please install pywin32') -APP_ROOT = libs.util.module_path() +APP_ROOT = libs.util.module_path(parent=True) # init preliminaries SYS_ARGV = sys.argv[1:] diff --git a/libs/util.py b/libs/util.py index df43c3fb..5ac9f943 100644 --- a/libs/util.py +++ b/libs/util.py @@ -9,14 +9,15 @@ __all__ = [ ] -def module_path(module=__file__): +def module_path(module=__file__, parent=False): try: path = module.__file__ except AttributeError: path = module directory = os.path.dirname(path) - parent = os.path.join(directory, os.pardir) - absolute = os.path.abspath(parent) + if parent: + directory = os.path.join(directory, os.pardir) + absolute = os.path.abspath(directory) normalized = os.path.normpath(absolute) return normalized