From 05f061bccbfb1e49f8af7d0f0606d87a408fb167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9munaire?= Date: Thu, 4 Oct 2012 13:59:37 +0200 Subject: [PATCH] In module, new variable DIR hold the directory path containing the module --- importer.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/importer.py b/importer.py index fd8523e..f4c011f 100644 --- a/importer.py +++ b/importer.py @@ -66,9 +66,11 @@ class ModuleLoader(SourceLoader): if os.path.isfile(path + fullname + ".py"): self.source_path = path + self.name + ".py" self.package = False + self.mpath = path elif os.path.isfile(path + fullname + "/__init__.py"): self.source_path = path + self.name + "/__init__.py" self.package = True + self.mpath = path + self.name + "/" else: raise ImportError @@ -144,6 +146,7 @@ class ModuleLoader(SourceLoader): # Set module common functions and datas module.REGISTERED_HOOKS = list() module.DEBUG = False + module.DIR = self.mpath module.name = fullname module.print = lambda msg: print("[%s] %s"%(module.name, msg)) module.print_debug = lambda msg: mod_print_dbg(module, msg)