def loadMacros():
path = os.path.abspath(os.path.dirname(__file__))
p = lambda x: os.path.splitext(x)[1] == ".py"
modules = [x for x in os.listdir(path) if p(x) and not x == "__init__.py"]
macros = {}
for module in modules:
name, _ = os.path.splitext(module)
moduleName = "%s.%s" % (__package__, name)
m = __import__(moduleName, globals(), locals(), __package__)
p = lambda x: isfunction(x) and getmodule(x) is m
for name, function in getmembers(m, p):
name = name.replace("_", "-")
try:
macros[name] = function
except Exception, e:
continue
return macros
评论列表
文章目录