Esempio n. 1
0
 def test_lib_mixins_basics(self):
     s_mixins.addSynMixin('ut', 'synapse.tests.test_lib_mixins.Foo')
     s_mixins.addSynMixin('ut', 'synapse.tests.test_lib_mixins.Baz',
                          'synapse.tests.test_lib_mixins.Bar')
     self.eq(
         s_mixins.getSynMixins('ut',
                               'synapse.tests.test_lib_mixins.Foo')[0], Foo)
     self.eq(
         s_mixins.getSynMixins('ut',
                               'synapse.tests.test_lib_mixins.Baz')[0], Bar)
Esempio n. 2
0
    def reflectItem(self):
        refl = s_reflect.getItemInfo(self.item)
        if refl is None:
            return

        for name in refl.get('inherits', ()):
            for mixi in s_mixins.getSynMixins('cmdr', name):
                self.addCmdClass(mixi)
Esempio n. 3
0
def getItemCmdr(item, outp=None, **opts):
    '''
    Construct and return a cmdr for the given item.

    Example:

        cmdr = getItemCmdr(foo)

    '''
    cmdr = s_cli.Cli(item, outp=outp)

    refl = s_reflect.getItemInfo(item)
    if refl is None:
        return cmdr

    for name in refl.get('inherits', ()):
        for mixi in s_mixins.getSynMixins('cmdr', name):
            cmdr.addCmdClass(mixi)

    return cmdr