Allow folder syntax in conf for hooks
@@ -63,8 +63,9 @@ class HookManager(object):
self.load_hook(name)
def load_hook(self, hook_name):
- filename = "%s.py" % hook_name
- hook_path = os.path.join(self._hooks_folder, filename)
+ if not hook_name.endswith(".py"):
+ hook_name = "%s.py" % hook_name
+ hook_path = os.path.normpath(os.path.join(self._hooks_folder, hook_name))
try:
hook = HookManager._load_module_from_file(hook_path)
for method in valid_hook_methods:
@@ -72,9 +73,9 @@ class HookManager(object):
if hook_method:
self.hooks[method].append((hook_name, hook_method))
except NotFoundException:
- self.output.warn("Hook '%s' not found in %s folder. Please remove hook "
- "from conan.conf or include it inside the hooks folder."
- % (filename, self._hooks_folder))
+ self.output.warn("Hook '%s' not found in %s folder. Please remove hook from conan.conf "
+ "or include it inside the hooks folder." % (hook_name,
+ self._hooks_folder))
except Exception as e:
raise ConanException("Error loading hook '%s': %s" % (hook_path, str(e)))
@@ -114,5 +115,4 @@ class HookManager(object):
finally:
sys.dont_write_bytecode = False
sys.path.pop()
-
return loaded
