コード例 #1
0
ファイル: basesupport.py プロジェクト: 0004c/VTK
    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
ファイル: basesupport.py プロジェクト: 0004c/VTK
    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_")
コード例 #3
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_")
コード例 #4
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_")
コード例 #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
ファイル: test_reflect.py プロジェクト: DT021/wau
 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
ファイル: test_reflect.py プロジェクト: DT021/wau
 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)
コード例 #10
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_")
コード例 #11
0
ファイル: basesupport.py プロジェクト: 0004c/VTK
    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))
コード例 #13
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))
コード例 #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
ファイル: tasks.py プロジェクト: tomprince/braid
    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}
コード例 #17
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"))
コード例 #18
0
ファイル: tasks.py プロジェクト: OpenSorceress/braid
    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
ファイル: tasks.py プロジェクト: twisted-infra/braid
    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)
コード例 #22
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))
コード例 #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
ファイル: lint.py プロジェクト: levanhong05/MeshMagic
 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
ファイル: thrillhouse.py プロジェクト: alg-a/scenic
        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()
コード例 #27
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))
コード例 #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
ファイル: test_assertions.py プロジェクト: swift1911/twisted
 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
ファイル: test_assertions.py プロジェクト: swift1911/twisted
 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
ファイル: lint.py プロジェクト: AnthonyNystrom/YoGoMee
 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")