Table of Contents

Module: reflect | Twisted-0.19.0/twisted/python/reflect.py
--- | ---
Standardized versions of various cool things that you can do with Python's reflection capabilities. This should probably involve metaclasses somehow, but I don't understand them, so nyah :-)
Imported modules |
--- | ---
import cStringIO import failure import os import pickle import reference import string import sys import types
Functions |
_reclass _startswith accumulateBases accumulateClassDict accumulateClassList accumulateMethods addMethodNamesToDict allYourBase currentThread filenameToModuleName | findInstances fullFuncName funcinfo getcurrent isLike isOfType isSame isinst macro modgrep | namedModule namedObject objgrep prefixedMethodNames prefixedMethods qual refrump safe_repr
| _reclass
    _reclass ( clazz )
| _startswith
    _startswith ( s,  sub )
| accumulateBases
    accumulateBases (
            classObj,
            l,
            baseClass=None,
            )
| accumulateClassDict
    accumulateClassDict (
            classObj,
            attr,
            dict,
            baseClass=None,
            )
### Accumulate all attributes of a given name in a class heirarchy into a single dictionary. Assuming all class attributes of this name are dictionaries. If any of the dictionaries being accumulated have the same key, the one highest in the class heirarchy wins. (XXX: If "higest" means "closest to the starting class".) Ex:: | class Soy: | properties = {"taste": "bland"} | | class Plant: | properties = {"colour": "green"} | | class Seaweed(Plant): | pass | | class Lunch(Soy, Seaweed): | properties = {"vegan": 1 } | | dct = {} | | accumulateClassDict(Lunch, "properties", dct) | | print dct {"taste": "bland", "colour": "green", "vegan": 1}
| accumulateClassList
    accumulateClassList (
            classObj,
            attr,
            listObj,
            baseClass=None,
            )
### Accumulate all attributes of a given name in a class heirarchy into a single list. Assuming all class attributes of this name are lists.
| accumulateMethods
    accumulateMethods (
            obj,
            dict,
            prefix='',
            curClass=None,
            )
accumulateMethods(instance, dict, prefix) I recurse through the bases of instance.__class__, and add methods beginning with `prefix` to `dict`, in the form of {'methodname':instancemethod_object}.
| addMethodNamesToDict
    addMethodNamesToDict (
            classObj,
            dict,
            prefix,
            baseClass=None,
            )
addMethodNamesToDict(classObj, dict, prefix, baseClass=None) -> dict this goes through `classObj` (and it's bases) and puts method names starting with `prefix` in `dict` with a value of 1. if baseClass isn't None, methods will only be added if classObj is-a baseClass If the class in question has the methods `prefix_methodname` and `prefix_methodname2`, the resulting dict should look something like: {"methodname": 1, "methodname2": 1}.
| allYourBase
    allYourBase ( classObj,  baseClass=None )
allYourBase(classObj, baseClass=None) -> list of all base classes that are subclasses of baseClass, unless it is None, in which case all bases will be added.
| currentThread
    currentThread ()
| filenameToModuleName
    filenameToModuleName ( fn )
### Convert a name in the filesystem to the name of the Python module it is. This is agressive about getting a module name back from a file; it will always return a string. Agressive means 'sometimes wrong'; it won't look at the Python path or try to do any error checking: don't use this method unless you already know that the filename you're talking about is a Python module.
| findInstances
    findInstances ( start,  t )
| fullFuncName
    fullFuncName ( func )
| funcinfo
    funcinfo ( function )
this is more documentation for myself than useful code.
| getcurrent
    getcurrent ( clazz )
| isLike
    isLike ( a,  b )
| isOfType
    isOfType ( start,  goal )
| isSame
    isSame ( a,  b )
| isinst
    isinst ( inst,  clazz )
| macro
    macro (
            name,
            filename,
            source,
            **identifiers,
            )
### macro(name, source, **identifiers) This allows you to create macro-like behaviors in python. See twisted.python.hook for an example of its usage.
| modgrep
    modgrep ( goal )
| namedModule
    namedModule ( name )
Return a module give it's name.
| namedObject
    namedObject ( name )
Get a fully named module-global object.
| objgrep
    objgrep (
            start,
            goal,
            eq=isLike,
            path='',
            paths=None,
            seen=None,
            )
An insanely CPU-intensive process for finding stuff.
| prefixedMethodNames
    prefixedMethodNames ( classObj,  prefix )
A list of method names with a given prefix in a given class.
| prefixedMethods
    prefixedMethods ( obj,  prefix )
A list of methods with a given prefix on a given instance.
| qual
    qual ( clazz )
| refrump
    refrump ( obj )
| safe_repr
    safe_repr ( obj )
safe_repr(anything) -> string Returns a string representation of an object (or a traceback, if that object's __repr__ raised an exception)
Classes |
Accessor | Extending this class will give you explicit accessor methods; a
Promise | I represent an object not yet available.
QueueMethod | I represent a method that doesn't exist yet.
Settable | A mixin class for syntactic sugar. Lets you assign attributes by
Summer | Extend from this class to get the capability to maintain 'related
ThreadAttr |

Table of Contents

This document was automatically generated on Sun Jul 14 19:53:11 2002 by HappyDoc version 2.0