Add path parent option to module path and default to using local path

This commit is contained in:
Labrys of Knossos 2018-12-19 19:09:48 -05:00
commit 339d2878b4
2 changed files with 5 additions and 4 deletions

View file

@ -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