Пример #1
0
    def getGroupCommands(self):
        """finds group commands

        these commands are methods on me that start with imgroup_; they are
        called with no arguments
        """
        return prefixedMethods(self, "imgroup_")
Пример #2
0
    def getPersonCommands(self):
        """finds person commands

        these commands are methods on me that start with imperson_; they are
        called with no arguments
        """
        return prefixedMethods(self, "imperson_")
    def getGroupCommands(self):
        """finds group commands

        these commands are methods on me that start with imgroup_; they are
        called with no arguments
        """
        return prefixedMethods(self, "imgroup_")
    def getPersonCommands(self):
        """finds person commands

        these commands are methods on me that start with imperson_; they are
        called with no arguments
        """
        return prefixedMethods(self, "imperson_")
Пример #5
0
 def __init__(self):
     self.xml = gtk.glade.XML(util.sibpath(__file__,"gladereactor.glade"))
     d = {}
     for m in reflect.prefixedMethods(self, "on_"):
         d[m.im_func.__name__] = m
     self.xml.signal_autoconnect(d)
     self.xml.get_widget('window1').connect('destroy',
                                            lambda w: self.stop())
     self.servers = self.xml.get_widget("servertree")
     sel = self.servers.get_selection()
     sel.set_mode(gtk.SELECTION_SINGLE)
     sel.connect("changed",
                 self.servers_selection_changed)
     self.xml.get_widget('suspend').set_sensitive(0)
     self.xml.get_widget('disconnect').set_sensitive(0)
     self.model = gtk.ListStore(str, object, gobject.TYPE_BOOLEAN,
                                gobject.TYPE_BOOLEAN)
     self.servers.set_model(self.model)
     self.servers.set_reorderable(1)
     self.servers.set_headers_clickable(1)
     for col in [
         gtk.TreeViewColumn('Server',
                            gtk.CellRendererText(),
                            text=0),
         gtk.TreeViewColumn('Reading',
                            gtk.CellRendererToggle(),
                            active=2),
         gtk.TreeViewColumn('Writing',
                            gtk.CellRendererToggle(),
                            active=3)]:
         self.servers.append_column(col)
         col.set_resizable(1)
     sup.__init__(self)
Пример #6
0
 def test_prefix(self):
     """
     If a prefix is given, L{prefixedMethods} returns only methods named
     with that prefix.
     """
     x = Separate()
     output = prefixedMethods(x, 'good_')
     self.assertEqual([x.good_method], output)
Пример #7
0
 def test_prefix(self):
     """
     If a prefix is given, L{prefixedMethods} returns only methods named
     with that prefix.
     """
     x = Separate()
     output = prefixedMethods(x, 'good_')
     self.assertEqual([x.good_method], output)
Пример #8
0
 def test_onlyObject(self):
     """
     L{prefixedMethods} returns a list of the methods discovered on an
     object.
     """
     x = Base()
     output = prefixedMethods(x)
     self.assertEqual([x.method], output)
Пример #9
0
 def test_onlyObject(self):
     """
     L{prefixedMethods} returns a list of the methods discovered on an
     object.
     """
     x = Base()
     output = prefixedMethods(x)
     self.assertEqual([x.method], output)
    def getTargetCommands(self, target):
        """finds group commands

        these commands are methods on me that start with imgroup_; they are
        called with a user present within this room as an argument

        you may want to override this in your group in order to filter for
        appropriate commands on the given user
        """
        return prefixedMethods(self, "imtarget_")
Пример #11
0
    def getTargetCommands(self, target):
        """finds group commands

        these commands are methods on me that start with imgroup_; they are
        called with a user present within this room as an argument

        you may want to override this in your group in order to filter for
        appropriate commands on the given user
        """
        return prefixedMethods(self, "imtarget_")
Пример #12
0
 def test_failUnlessMatchesAssert(self):
     """
     The C{failUnless*} test methods are a subset of the C{assert*} test
     methods.  This is intended to ensure that methods using the
     I{failUnless} naming scheme are not added without corresponding methods
     using the I{assert} naming scheme.  The I{assert} naming scheme is
     preferred, and new I{assert}-prefixed methods may be added without
     corresponding I{failUnless}-prefixed methods.
     """
     asserts = set(self._getAsserts())
     failUnlesses = set(prefixedMethods(self, 'failUnless'))
     self.assertEqual(failUnlesses, asserts.intersection(failUnlesses))
 def test_failUnlessMatchesAssert(self):
     """
     The C{failUnless*} test methods are a subset of the C{assert*} test
     methods.  This is intended to ensure that methods using the
     I{failUnless} naming scheme are not added without corresponding methods
     using the I{assert} naming scheme.  The I{assert} naming scheme is
     preferred, and new I{assert}-prefixed methods may be added without
     corresponding I{failUnless}-prefixed methods.
     """
     asserts = set(self._getAsserts())
     failUnlesses = set(prefixedMethods(self, "failUnless"))
     self.assertEqual(failUnlesses, asserts.intersection(failUnlesses))
Пример #14
0
 def _replaceAppMethods(self):
     """
     Mask over methods in the L{app} module with methods from this class
     that start with 'app_'.
     """
     prefix = 'app_'
     replacedMethods = {}
     for method in prefixedMethods(self, 'app_'):
         name = method.__name__[len(prefix):]
         replacedMethods[name] = getattr(app, name)
         setattr(app, name, method)
     return replacedMethods
Пример #15
0
    def getTasks(self):
        """
        Get all tasks of this L{Service} object.

        Intended to be used like::

            globals().update(Service('name').getTasks())

        at the module level of a fabfile.

        @returns: L{dict} of L{fabric.tasks.Task}
        """
        tasks = [(t, _stripPrefix(t))
                 for t in prefixedMethods(self, TASK_PREFIX)]
        return {name: task(name=name)(t) for t, name in tasks}
Пример #16
0
    def getTasks(self):
        """
        Get all tasks of this L{Service} object.

        Intended to be used like::

            globals().update(Service('name').getTasks())

        at the module level of a fabfile.

        @returns: L{dict} of L{fabric.tasks.Task}
        """
        tasks = [(t, _stripPrefix(t))
                 for t in prefixedMethods(self, TASK_PREFIX)]
        return {name: task(name=name)(t) for t, name in tasks}
 def __init__(self, o=None):
     self.xml = x = gtk.glade.XML(sibpath(__file__, "inspectro.glade"))
     self.tree_view = x.get_widget("treeview")
     colnames = ["Name", "Value"]
     for i in range(len(colnames)):
         self.tree_view.append_column(gtk.TreeViewColumn(colnames[i], gtk.CellRendererText(), text=i))
     d = {}
     for m in reflect.prefixedMethods(self, "on_"):
         d[m.im_func.__name__] = m
     self.xml.signal_autoconnect(d)
     if o is not None:
         self.inspect(o)
     self.ns = {"inspect": self.inspect}
     iwidget = x.get_widget("input")
     self.input = ConsoleInput(iwidget)
     self.input.toplevel = self
     iwidget.connect("key_press_event", self.input._on_key_press_event)
     self.output = ConsoleOutput(x.get_widget("output"))
Пример #18
0
    def getTasks(self, role=None):
        """
        Get all tasks of this L{Service} object.

        Intended to be used like::

            globals().update(Service('name').getTasks())

        at the module level of a fabfile.

        @returns: L{dict} of L{fabric.tasks.Task}
        """
        tasks = prefixedMethods(self, TASK_PREFIX)
        tasks = ((_stripPrefix(t), t) for t in tasks)
        tasks = ((name, task(name=name)(t)) for name, t in tasks)

        if role:
            tasks = ((name, roles(role)(t)) for name, t in tasks)

        return dict(tasks)
Пример #19
0
 def __init__(self, o=None):
     self.xml = x = gtk.glade.XML(sibpath(__file__, "inspectro.glade"))
     self.tree_view = x.get_widget("treeview")
     colnames = ["Name", "Value"]
     for i in range(len(colnames)):
         self.tree_view.append_column(
             gtk.TreeViewColumn(colnames[i], gtk.CellRendererText(),
                                text=i))
     d = {}
     for m in reflect.prefixedMethods(self, "on_"):
         d[m.im_func.__name__] = m
     self.xml.signal_autoconnect(d)
     if o is not None:
         self.inspect(o)
     self.ns = {'inspect': self.inspect}
     iwidget = x.get_widget('input')
     self.input = ConsoleInput(iwidget)
     self.input.toplevel = self
     iwidget.connect("key_press_event", self.input._on_key_press_event)
     self.output = ConsoleOutput(x.get_widget('output'))
Пример #20
0
    def getTasks(self, role=None):
        """
        Get all tasks of this L{Service} object.

        Intended to be used like::

            globals().update(Service('name').getTasks())

        at the module level of a fabfile.

        @returns: L{dict} of L{fabric.tasks.Task}
        """
        tasks = prefixedMethods(self, TASK_PREFIX)
        tasks = ((_stripPrefix(t), t) for t in tasks)
        tasks = ((name, task(name=name)(t)) for name, t in tasks)

        if role:
            tasks = ((name, roles(role)(t)) for name, t in tasks)

        return dict(tasks)
Пример #21
0
    def __init__(self):
        self.xml = gtk.glade.XML(util.sibpath(__file__, "gladereactor.glade"))
        d = {}
        for m in reflect.prefixedMethods(self, "on_"):
            d[m.im_func.__name__] = m
        self.xml.signal_autoconnect(d)
        self.xml.get_widget('window1').connect('destroy',
                                               lambda w: self.stop())
        self.servers = self.xml.get_widget("servertree")
        sel = self.servers.get_selection()
        sel.set_mode(gtk.SELECTION_SINGLE)
        sel.connect("changed", self.servers_selection_changed)
        ## argh coredump: self.servers_selection_changed(sel)
        self.xml.get_widget('suspend').set_sensitive(0)
        self.xml.get_widget('disconnect').set_sensitive(0)
        # setup model, connect it to my treeview
        self.model = gtk.ListStore(str, object, gobject.TYPE_BOOLEAN,
                                   gobject.TYPE_BOOLEAN)
        self.servers.set_model(self.model)
        self.servers.set_reorderable(1)
        self.servers.set_headers_clickable(1)
        # self.servers.set_headers_draggable(1)
        # add a column
        for col in [
                gtk.TreeViewColumn('Server', gtk.CellRendererText(), text=0),
                gtk.TreeViewColumn('Reading',
                                   gtk.CellRendererToggle(),
                                   active=2),
                gtk.TreeViewColumn('Writing',
                                   gtk.CellRendererToggle(),
                                   active=3)
        ]:

            self.servers.append_column(col)
            col.set_resizable(1)
        sup.__init__(self)
 def test_failIf_matches_assertNot(self):
     asserts = reflect.prefixedMethods(unittest.TestCase, 'assertNot')
     failIfs = reflect.prefixedMethods(unittest.TestCase, 'failIf')
     self.failUnlessEqual(dsu(asserts, self._name),
                          dsu(failIfs, self._name))
Пример #23
0
 def test_failIf_matches_assertNot(self):
     asserts = prefixedMethods(unittest.SynchronousTestCase, 'assertNot')
     failIfs = prefixedMethods(unittest.SynchronousTestCase, 'failIf')
     self.assertEqual(sorted(asserts, key=self._name),
                          sorted(failIfs, key=self._name))
Пример #24
0
 def check(self, dom, filename):
     self.hadErrors = 0
     for method in reflect.prefixedMethods(self, 'check_'):
         method(dom, filename)
     if self.hadErrors:
         raise process.ProcessingFailure("invalid format")
Пример #25
0
        recv.videocodec = 'h264'
        send.videocodec = recv.videocodec
        self.run(recv, send)

    def test_51_h263_sharedvideosink(self):
        """ Test with sharedvideosink """
        recv, send = self.argfactory('video')

        recv.videosink = 'sharedvideosink'
        recv.videocodec = 'h263'
        send.videocodec = recv.videocodec
        self.run(recv, send)

    def test_52_theora_deinterlace_sharedvideosink(self):
        """ Test with sharedvideosink """
        recv, send = self.argfactory('video')
        recv.videosink = 'sharedvideosink'
        recv.videocodec = 'theora'
        send.videocodec = recv.videocodec
        recv.deinterlace = True
        self.run(recv, send)

if __name__ == '__main__':
    # here we run all the tests thanks to the wonders of reflective programming
    TESTS = prefixedMethods(MilhouseTests(), 'test_01')

    for test in TESTS:
        print 'TEST: '  + test.__doc__
        test()

Пример #26
0
        recv.videocodec = 'h264'
        send.videocodec = recv.videocodec
        self.run(recv, send)

    def test_51_h263_sharedvideosink(self):
        """ Test with sharedvideosink """
        recv, send = self.argfactory('video')

        recv.videosink = 'sharedvideosink'
        recv.videocodec = 'h263'
        send.videocodec = recv.videocodec
        self.run(recv, send)

    def test_52_theora_deinterlace_sharedvideosink(self):
        """ Test with sharedvideosink """
        recv, send = self.argfactory('video')
        recv.videosink = 'sharedvideosink'
        recv.videocodec = 'theora'
        send.videocodec = recv.videocodec
        recv.deinterlace = True
        self.run(recv, send)


if __name__ == '__main__':
    # here we run all the tests thanks to the wonders of reflective programming
    TESTS = prefixedMethods(MilhouseTests(), 'test_01')

    for test in TESTS:
        print 'TEST: ' + test.__doc__
        test()
 def test_failUnless_matches_assert(self):
     asserts = self._getAsserts()
     failUnlesses = reflect.prefixedMethods(self, 'failUnless')
     self.failUnlessEqual(dsu(asserts, self._name),
                          dsu(failUnlesses, self._name))
Пример #28
0
 def test_failIf_matches_assertNot(self):
     asserts = reflect.prefixedMethods(unittest.TestCase, "assertNot")
     failIfs = reflect.prefixedMethods(unittest.TestCase, "failIf")
     self.assertEqual(sorted(asserts, key=self._name), sorted(failIfs, key=self._name))
Пример #29
0
 def test_failIf_matches_assertNot(self):
     asserts = reflect.prefixedMethods(unittest.TestCase, 'assertNot')
     failIfs = reflect.prefixedMethods(unittest.TestCase, 'failIf')
     self.failUnlessEqual(dsu(asserts, self._name),
                          dsu(failIfs, self._name))
Пример #30
0
 def test_failUnless_matches_assert(self):
     asserts = self._getAsserts()
     failUnlesses = reflect.prefixedMethods(self, 'failUnless')
     self.failUnlessEqual(dsu(asserts, self._name),
                          dsu(failUnlesses, self._name))
Пример #31
0
 def check(self, dom, filename):
     self.hadErrors = 0
     for method in reflect.prefixedMethods(self, 'check_'):
         method(dom, filename)
     if self.hadErrors:
         raise process.ProcessingFailure("invalid format")