Python twisted.python.reflect.prefixedMethodNames() Examples
The following are 30
code examples of twisted.python.reflect.prefixedMethodNames().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
twisted.python.reflect
, or try the search function
.
Example #1
Source File: tkmktap.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
def setupOptFlags(self): self.optFlags = [] flags = [] if hasattr(self.options, 'optFlags'): flags.extend(self.options.optFlags) d = {} soFar = {} for meth in reflect.prefixedMethodNames(self.options.__class__, 'opt_'): full = 'opt_' + meth func = getattr(self.options, full) if not usage.flagFunction(func) or meth in ('help', 'version'): continue if soFar.has_key(func): continue soFar[func] = 1 existing = d.setdefault(func, meth) if existing != meth: if len(existing) < len(meth): d[func] = meth for (func, name) in d.items(): flags.append((name, None, func.__doc__)) if len(flags): self.optFrame = f = Tkinter.Frame(self) for (flag, _, desc) in flags: b = Tkinter.BooleanVar() c = Tkinter.Checkbutton(f, text=desc, variable=b, wraplen=200) c.pack(anchor=Tkinter.W) self.optFlags.append((flag, b)) f.grid(row=1, column=1)
Example #2
Source File: xmlrpc.py From python-for-android with Apache License 2.0 | 5 votes |
def _listFunctions(self): """ Return a list of the names of all xmlrpc methods. """ return reflect.prefixedMethodNames(self.__class__, 'xmlrpc_')
Example #3
Source File: gtkutil.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def getButtonList(self, prefix='button_', container=None): result = [] buttons = self.barButtons or \ reflect.prefixedMethodNames(self.__class__, prefix) for b in buttons: bName = string.replace(b, '_', ' ') result.append(cbutton(bName, getattr(self,prefix+b))) if container: map(container.add, result) return result
Example #4
Source File: test_nmea.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def connectionMade(self): self.resultHarvester = ResultHarvester() for fn in reflect.prefixedMethodNames(self.__class__, 'decode_'): setattr(self, 'handle_' + fn, self.resultHarvester)
Example #5
Source File: runner.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def getTestCaseNames(self, klass): return reflect.prefixedMethodNames(klass, self.methodPrefix)
Example #6
Source File: irc.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def ctcpQuery_CLIENTINFO(self, user, channel, data): """A master index of what CTCP tags this client knows. If no arguments are provided, respond with a list of known tags. If an argument is provided, provide human-readable help on the usage of that tag. """ nick = string.split(user,"!")[0] if not data: # XXX: prefixedMethodNames gets methods from my *class*, # but it's entirely possible that this *instance* has more # methods. names = reflect.prefixedMethodNames(self.__class__, 'ctcpQuery_') self.ctcpMakeReply(nick, [('CLIENTINFO', string.join(names, ' '))]) else: args = string.split(data) method = getattr(self, 'ctcpQuery_%s' % (args[0],), None) if not method: self.ctcpMakeReply(nick, [('ERRMSG', "CLIENTINFO %s :" "Unknown query '%s'" % (data, args[0]))]) return doc = getattr(method, '__doc__', '') self.ctcpMakeReply(nick, [('CLIENTINFO', doc)])
Example #7
Source File: xmlrpc.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def _listFunctions(self): """Return a list of the names of all xmlrpc methods.""" return reflect.prefixedMethodNames(self.__class__, 'xmlrpc_')
Example #8
Source File: sux.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def prefixedMethodClassDict(clazz, prefix): return dict([(name, getattr(clazz, prefix + name)) for name in prefixedMethodNames(clazz, prefix)])
Example #9
Source File: twisted_brpc.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def _listFunctions(self): """Return a list of the names of all brpc methods.""" return reflect.prefixedMethodNames(self.__class__, 'brpc_')
Example #10
Source File: twisted_ebrpc.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def _listFunctions(self): """Return a list of the names of all ebrpc methods.""" return reflect.prefixedMethodNames(self.__class__, 'ebrpc_')
Example #11
Source File: twisted_brpc.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def _listFunctions(self): """Return a list of the names of all brpc methods.""" return reflect.prefixedMethodNames(self.__class__, 'brpc_')
Example #12
Source File: twisted_ebrpc.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def _listFunctions(self): """Return a list of the names of all ebrpc methods.""" return reflect.prefixedMethodNames(self.__class__, 'ebrpc_')
Example #13
Source File: test_nmea.py From python-for-android with Apache License 2.0 | 5 votes |
def connectionMade(self): self.resultHarvester = ResultHarvester() for fn in reflect.prefixedMethodNames(self.__class__, 'decode_'): setattr(self, 'handle_' + fn, self.resultHarvester)
Example #14
Source File: test_gtk2manhole.py From python-for-android with Apache License 2.0 | 5 votes |
def test_reverseKeymap(self): """ Verify that a L{ConsoleInput} has a reverse mapping of the keysym names it needs for event handling to their corresponding keysym. """ ci = ConsoleInput(None) for eventName in prefixedMethodNames(ConsoleInput, 'key_'): keysymName = eventName.split("_")[-1] keysymValue = getattr(gtk.keysyms, keysymName) self.assertEqual(ci.rkeymap[keysymValue], keysymName)
Example #15
Source File: runner.py From python-for-android with Apache License 2.0 | 5 votes |
def getTestCaseNames(self, klass): """ Given a class that contains C{TestCase}s, return a list of names of methods that probably contain tests. """ return reflect.prefixedMethodNames(klass, self.methodPrefix)
Example #16
Source File: irc.py From python-for-android with Apache License 2.0 | 5 votes |
def ctcpQuery_CLIENTINFO(self, user, channel, data): """A master index of what CTCP tags this client knows. If no arguments are provided, respond with a list of known tags. If an argument is provided, provide human-readable help on the usage of that tag. """ nick = string.split(user,"!")[0] if not data: # XXX: prefixedMethodNames gets methods from my *class*, # but it's entirely possible that this *instance* has more # methods. names = reflect.prefixedMethodNames(self.__class__, 'ctcpQuery_') self.ctcpMakeReply(nick, [('CLIENTINFO', string.join(names, ' '))]) else: args = string.split(data) method = getattr(self, 'ctcpQuery_%s' % (args[0],), None) if not method: self.ctcpMakeReply(nick, [('ERRMSG', "CLIENTINFO %s :" "Unknown query '%s'" % (data, args[0]))]) return doc = getattr(method, '__doc__', '') self.ctcpMakeReply(nick, [('CLIENTINFO', doc)])
Example #17
Source File: sux.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def prefixedMethodClassDict(clazz, prefix): return dict([(name, getattr(clazz, prefix + name)) for name in prefixedMethodNames(clazz, prefix)])
Example #18
Source File: sux.py From python-for-android with Apache License 2.0 | 5 votes |
def prefixedMethodObjDict(obj, prefix): return dict([(name, getattr(obj, prefix + name)) for name in prefixedMethodNames(obj.__class__, prefix)])
Example #19
Source File: sux.py From python-for-android with Apache License 2.0 | 5 votes |
def prefixedMethodClassDict(clazz, prefix): return dict([(name, getattr(clazz, prefix + name)) for name in prefixedMethodNames(clazz, prefix)])
Example #20
Source File: xmlrpc.py From peach with Mozilla Public License 2.0 | 5 votes |
def listProcedures(self): """ Return a list of the names of all xmlrpc procedures. @since: 11.1 """ return reflect.prefixedMethodNames(self.__class__, 'xmlrpc_')
Example #21
Source File: irc.py From learn_python3_spider with MIT License | 5 votes |
def ctcpQuery_CLIENTINFO(self, user, channel, data): """ A master index of what CTCP tags this client knows. If no arguments are provided, respond with a list of known tags, sorted in alphabetical order. If an argument is provided, provide human-readable help on the usage of that tag. """ nick = user.split('!')[0] if not data: # XXX: prefixedMethodNames gets methods from my *class*, # but it's entirely possible that this *instance* has more # methods. names = sorted(reflect.prefixedMethodNames(self.__class__, 'ctcpQuery_')) self.ctcpMakeReply(nick, [('CLIENTINFO', ' '.join(names))]) else: args = data.split() method = getattr(self, 'ctcpQuery_%s' % (args[0],), None) if not method: self.ctcpMakeReply(nick, [('ERRMSG', "CLIENTINFO %s :" "Unknown query '%s'" % (data, args[0]))]) return doc = getattr(method, '__doc__', '') self.ctcpMakeReply(nick, [('CLIENTINFO', doc)])
Example #22
Source File: resource.py From learn_python3_spider with MIT License | 5 votes |
def _computeAllowedMethods(resource): """ Compute the allowed methods on a C{Resource} based on defined render_FOO methods. Used when raising C{UnsupportedMethod} but C{Resource} does not define C{allowedMethods} attribute. """ allowedMethods = [] for name in prefixedMethodNames(resource.__class__, "render_"): # Potentially there should be an API for encode('ascii') in this # situation - an API for taking a Python native string (bytes on Python # 2, text on Python 3) and returning a socket-compatible string type. allowedMethods.append(name.encode('ascii')) return allowedMethods
Example #23
Source File: xmlrpc.py From learn_python3_spider with MIT License | 5 votes |
def listProcedures(self): """ Return a list of the names of all xmlrpc procedures. @since: 11.1 """ return reflect.prefixedMethodNames(self.__class__, 'xmlrpc_')
Example #24
Source File: sux.py From learn_python3_spider with MIT License | 5 votes |
def prefixedMethodObjDict(obj, prefix): return dict([(name, getattr(obj, prefix + name)) for name in prefixedMethodNames(obj.__class__, prefix)])
Example #25
Source File: sux.py From learn_python3_spider with MIT License | 5 votes |
def prefixedMethodClassDict(clazz, prefix): return dict([(name, getattr(clazz, prefix + name)) for name in prefixedMethodNames(clazz, prefix)])
Example #26
Source File: sux.py From riko with MIT License | 5 votes |
def get_method_obj_dict(obj, prefix): names = find_method_names(obj.__class__, prefix) return {name: getattr(obj, prefix + name) for name in names}
Example #27
Source File: acceptance.py From flocker with Apache License 2.0 | 5 votes |
def _get_provider_names(self): """ Find the names of all supported "providers" (eg Vagrant, Rackspace). :return: A ``list`` of ``str`` giving all such names. """ return prefixedMethodNames(self.__class__, "_runner_")
Example #28
Source File: irc.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def ctcpQuery_CLIENTINFO(self, user, channel, data): """ A master index of what CTCP tags this client knows. If no arguments are provided, respond with a list of known tags, sorted in alphabetical order. If an argument is provided, provide human-readable help on the usage of that tag. """ nick = user.split('!')[0] if not data: # XXX: prefixedMethodNames gets methods from my *class*, # but it's entirely possible that this *instance* has more # methods. names = sorted(reflect.prefixedMethodNames(self.__class__, 'ctcpQuery_')) self.ctcpMakeReply(nick, [('CLIENTINFO', ' '.join(names))]) else: args = data.split() method = getattr(self, 'ctcpQuery_%s' % (args[0],), None) if not method: self.ctcpMakeReply(nick, [('ERRMSG', "CLIENTINFO %s :" "Unknown query '%s'" % (data, args[0]))]) return doc = getattr(method, '__doc__', '') self.ctcpMakeReply(nick, [('CLIENTINFO', doc)])
Example #29
Source File: resource.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def _computeAllowedMethods(resource): """ Compute the allowed methods on a C{Resource} based on defined render_FOO methods. Used when raising C{UnsupportedMethod} but C{Resource} does not define C{allowedMethods} attribute. """ allowedMethods = [] for name in prefixedMethodNames(resource.__class__, "render_"): # Potentially there should be an API for encode('ascii') in this # situation - an API for taking a Python native string (bytes on Python # 2, text on Python 3) and returning a socket-compatible string type. allowedMethods.append(name.encode('ascii')) return allowedMethods
Example #30
Source File: xmlrpc.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def listProcedures(self): """ Return a list of the names of all xmlrpc procedures. @since: 11.1 """ return reflect.prefixedMethodNames(self.__class__, 'xmlrpc_')