#$ neutron_plugin 01 import re import os LINES_LIMIT = 20 def handler_pydoc(type, source, params): params = re.split(r'\s+', params)[0] params = re.sub(r'[^-_.0-9a-zA-Z]', '', params) pipe = os.popen('sh -c "pydoc %s | head -n %d"' % (params, LINES_LIMIT)) # time.sleep(0.5) # 4k buffer equals to 2 standard console (80x25) pages. return_value = pipe.read(4096) smsg(type, source, return_value) #unicode(return_value, 'utf8')) register_command_handler(handler_pydoc, '!pydoc', 0, 'Display first %d lines from pydoc output.' % LINES_LIMIT, '!pydoc ', ['!pydoc os.path.join'])