summaryrefslogtreecommitdiff
path: root/python/londiste/handler.py
diff options
context:
space:
mode:
authorMarko Kreen2011-09-21 13:22:12 +0000
committerMarko Kreen2011-09-21 13:43:04 +0000
commitdf8fd7574c5f332c48eb11f48dab91a3bdcd329f (patch)
treee3e7d2944e8ebae4a2e1a614a5c6b8fbe448dc26 /python/londiste/handler.py
parent75fcfe3e6bd98ca91f83994bdc31adb2c266bfc3 (diff)
londiste x.ini show-handlers: info about handlers
Diffstat (limited to 'python/londiste/handler.py')
-rw-r--r--python/londiste/handler.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/python/londiste/handler.py b/python/londiste/handler.py
index 9e52db5f..aff0e4ce 100644
--- a/python/londiste/handler.py
+++ b/python/londiste/handler.py
@@ -146,12 +146,15 @@ _handler_map = {
'londiste': TableHandler,
}
+_handler_list = _handler_map.keys()
+
def register_handler_module(modname):
"""Import and module and register handlers."""
__import__(modname)
m = sys.modules[modname]
for h in m.__londiste_handlers__:
_handler_map[h.handler_name] = h
+ _handler_list.append(h.handler_name)
def _parse_arglist(arglist):
args = {}
@@ -203,3 +206,24 @@ def load_handler_modules(cf):
for m in lst:
register_handler_module(m)
+def show(mods):
+ if not mods:
+ if 0:
+ names = _handler_map.keys()
+ names.sort()
+ else:
+ names = _handler_list
+ for n in names:
+ kls = _handler_map[n]
+ desc = kls.__doc__ or ''
+ if desc:
+ desc = desc.split('\n', 1)[0]
+ print("%s - %s" % (n, desc))
+ else:
+ for n in mods:
+ kls = _handler_map[n]
+ desc = kls.__doc__ or ''
+ if desc:
+ desc = desc.rstrip()
+ print("%s - %s" % (n, desc))
+