예제 #1
0
 def test_getFirstSentence(self):
     """
     """
     # example 1
     original = " muh. "
     expected = "muh."
     self.assertEquals(getFirstSentence(original), expected)
     # example 2
     original = """
         muh maeh. blub
     """
     expected = "muh maeh."
     self.assertEquals(getFirstSentence(original), expected)
     # example 3
     original = "muh.maeh.blub."
     expected = "muh."
     self.assertEquals(getFirstSentence(original), expected)
     # example 4
     original = "m" * 600
     expected = "m" * 255
     self.assertEquals(getFirstSentence(original), expected)
     # example 4
     original = "m" * 600
     expected = "m" * 5
     self.assertEquals(getFirstSentence(original, 5), expected)
예제 #2
0
 def _viewPlugins(self, request, error=None):  # @UnusedVariable
     plugins = {}
     from seishub.core.core import ComponentMeta
     for component in ComponentMeta._components:
         try:
             module = sys.modules[component.__module__]
         except:
             continue
         description = getFirstSentence(inspect.getdoc(module))
         modulename = module.__name__
         classname = modulename + '.' + component.__name__
         plugin = {
           'name': component.__name__,
           'module': module.__name__,
           'file': module.__file__,
           'classname': classname,
           'description': getFirstSentence(inspect.getdoc(component)),
           'enabled': self.env.isComponentEnabled(classname),
           'required': classname in DEFAULT_COMPONENTS or \
                       modulename in DEFAULT_COMPONENTS,
         }
         packagename = '.'.join(modulename.split('.')[0:3])
         plugins.setdefault(packagename, {})
         plugins[packagename].setdefault(modulename, {})
         plugins[packagename][modulename].setdefault('plugins',
                                                     []).append(plugin)
         plugins[packagename][modulename]['description'] = description
     data = {
       'sorted_plugins': sorted(plugins),
       'plugins': plugins,
       'error': error,
     }
     return data
예제 #3
0
 def _viewPlugins(self, request, error=None):  # @UnusedVariable
     plugins = {}
     from seishub.core.core import ComponentMeta
     for component in ComponentMeta._components:
         try:
             module = sys.modules[component.__module__]
         except:
             continue
         description = getFirstSentence(inspect.getdoc(module))
         modulename = module.__name__
         classname = modulename + '.' + component.__name__
         plugin = {
           'name': component.__name__,
           'module': module.__name__,
           'file': module.__file__,
           'classname': classname,
           'description': getFirstSentence(inspect.getdoc(component)),
           'enabled': self.env.isComponentEnabled(classname),
           'required': classname in DEFAULT_COMPONENTS or \
                       modulename in DEFAULT_COMPONENTS,
         }
         packagename = '.'.join(modulename.split('.')[0:3])
         plugins.setdefault(packagename, {})
         plugins[packagename].setdefault(modulename, {})
         plugins[packagename][modulename].setdefault('plugins',
                                                     []).append(plugin)
         plugins[packagename][modulename]['description'] = description
     data = {
       'sorted_plugins': sorted(plugins),
       'plugins': plugins,
       'error': error,
     }
     return data
예제 #4
0
파일: ssh.py 프로젝트: barsch/seishub.core
 def cmd_HELP(self, *args):
     self.writeln('== Build-in keywords ==')
     for cmd in self.buildin_cmds:
         func = getattr(self, 'cmd_' + cmd, None)
         func_doc = func.__doc__
         if not func_doc:
             continue
         self.writeln(cmd + ' - ' + getFirstSentence(str(func_doc)))
     self.nextLine()
     self.writeln('== Plugin keywords ==')
     for cmd, plugin in self.plugin_cmds.items():
         self.writeln(cmd + ' - ' + getFirstSentence(str(plugin.__doc__)))
예제 #5
0
 def cmd_HELP(self, *args):
     self.writeln('== Build-in keywords ==')
     for cmd in self.buildin_cmds:
         func = getattr(self, 'cmd_' + cmd, None)
         func_doc = func.__doc__
         if not func_doc:
             continue
         self.writeln(cmd + ' - ' + getFirstSentence(str(func_doc)))
     self.nextLine()
     self.writeln('== Plugin keywords ==')
     for cmd, plugin in self.plugin_cmds.items():
         self.writeln(cmd + ' - ' + getFirstSentence(str(plugin.__doc__)))