t.p.util : module documentation

Part of twisted.python View Source

No module docstring
Class InsensitiveDict Dictionary, that has case-insensitive keys.
Class OrderedDict A UserDict that preserves insert order whenever possible.
Function uniquify Make the elements of a list unique by inserting them into a dictionary. This must not change the order of the input lst.
Function padTo Pads a sequence out to n elements,
Function getPluginDirs Undocumented
Function addPluginDir Undocumented
Function sibpath Return the path to a sibling of a file in the filesystem.
Function getPassword Obtain a password by prompting or from stdin.
Function dict Undocumented
Function println Undocumented
Function str_xor Undocumented
Function keyed_md5 Create the keyed MD5 string for the given secret and challenge.
Function makeStatBar Creates a function that will return a string representing a progress bar.
Function spewer A trace function for sys.settrace that prints every function or method call.
Function searchupwards Walk upwards from start, looking for a directory containing all files and directories given as arguments:: >>> searchupwards('.', ['foo.txt'], ['bar', 'bam'])
Class LineLog A limited-size line-based log, useful for logging line-based protocols such as SMTP.
Function raises Determine whether the given call raises the given exception
Class IntervalDifferential Given a list of intervals, generate the amount of time to sleep between "instants".
Class FancyStrMixin Set showAttributes to a sequence of strings naming attributes, OR sequences of (attributeName, displayName, formatCharacter)
Class FancyEqMixin Undocumented
Function dsu Undocumented
Function initgroups 0 Do nothing.
Function initgroups Initializes the group access list.
Function switchUID Undocumented
Class SubclassableCStringIO A wrapper around cStringIO to allow for subclassing
Function moduleMovedForSplit Undocumented
Function untilConcludes Undocumented
Function unsignedID Return the id of an object as an unsigned number so that its hex representation makes sense
Function mergeFunctionMetadata Overwrite g's name and docstring with values from f. Update g's instance dictionary with f's.
Function nameToLabel Convert a string like a variable name into a slightly more human-friendly string with spaces and capitalized letters.
Function uidFromString Convert a user identifier, as a string, into an integer UID.
Function gidFromString Convert a group identifier, as a string, into an integer GID.
Function _getpass Helper to turn IOErrors into KeyboardInterrupts
Class _IntervalDifferentialIterator Undocumented
Function _setgroups_until_success Undocumented
def uniquify(lst): (source)
Make the elements of a list unique by inserting them into a dictionary. This must not change the order of the input lst.
def padTo(n, seq, default=None): (source)

Pads a sequence out to n elements,

filling in with a default value if it is not long enough.

If the input sequence is longer than n, raises ValueError.

Details, details: This returns a new list; it does not extend the original sequence. The new list contains the values of the original sequence, not copies.
def getPluginDirs(): (source)
Undocumented
def addPluginDir(): (source)
Undocumented
def sibpath(path, sibling): (source)

Return the path to a sibling of a file in the filesystem.

This is useful in conjunction with the special __file__ attribute that Python provides for modules, so modules can load associated resource files.
def _getpass(prompt): (source)
Helper to turn IOErrors into KeyboardInterrupts
def getPassword(prompt='Password: ', confirm=0, forceTTY=0, confirmPrompt='Confirm password: ', mismatchMessage="Passwords don't match."): (source)

Obtain a password by prompting or from stdin.

If stdin is a terminal, prompt for a new password, and confirm (if confirm is true) by asking again to make sure the user typed the same thing, as keystrokes will not be echoed.

If stdin is not a terminal, and forceTTY is not true, read in a line and use it as the password, less the trailing newline, if any. If forceTTY is true, attempt to open a tty and prompt for the password using it. Raise a RuntimeError if this is not possible.
Returnsstr
def dict(*a, **k): (source)
Undocumented
def println(*a): (source)
Undocumented
def str_xor(s, b): (source)
Undocumented
def keyed_md5(secret, challenge): (source)
Create the keyed MD5 string for the given secret and challenge.
def makeStatBar(width, maxPosition, doneChar='=', undoneChar='-', currentChar='>'): (source)
Creates a function that will return a string representing a progress bar.
def spewer(frame, s, ignored): (source)
A trace function for sys.settrace that prints every function or method call.
def searchupwards(start, files=, dirs=): (source)
Walk upwards from start, looking for a directory containing all files and directories given as arguments:
>> searchupwards('.', ['foo.txt'], ['bar', 'bam'])
If not found, return None
def raises(exception, f, *args, **kwargs): (source)
Determine whether the given call raises the given exception
def dsu(list, key): (source)
Undocumented
def initgroups 0(uid, primaryGid): (source)

Do nothing.

Underlying platform support require to manipulate groups is missing.
def _setgroups_until_success(l): (source)
Undocumented
def initgroups(uid, primaryGid): (source)

Initializes the group access list.

This is done by reading the group database /etc/group and using all groups of which uid is a member. The additional group primaryGid is also added to the list.

If the given user is a member of more than NGROUPS, arbitrary groups will be silently discarded to bring the number below that limit.
ParametersuidThe UID for which to look up group information. (type: int )
primaryGidIf provided, an additional GID to include when setting the groups. (type: int or NoneType )
def switchUID(uid, gid, euid=False): (source)
Undocumented
def moduleMovedForSplit(origModuleName, newModuleName, moduleDesc, projectName, projectURL, globDict): (source)
Undocumented
def untilConcludes(f, *a, **kw): (source)
Undocumented
def unsignedID(obj): (source)
Return the id of an object as an unsigned number so that its hex representation makes sense
def mergeFunctionMetadata(f, g): (source)

Overwrite g's name and docstring with values from f. Update g's instance dictionary with f's.

To use this function safely you must use the return value. In Python 2.3, mergeFunctionMetadata will create a new function. In later versions of Python, g will be mutated and returned.
ReturnsA function that has g's behavior and metadata merged from f.
def nameToLabel(mname): (source)
Convert a string like a variable name into a slightly more human-friendly string with spaces and capitalized letters.
ParametersmnameThe name to convert to a label. This must be a string which could be used as a Python identifier. Strings which do not take this form will result in unpredictable behavior. (type: str )
Returns (type: str )
def uidFromString(uidString): (source)
Convert a user identifier, as a string, into an integer UID.
ParametersuidA string giving the base-ten representation of a UID or the name of a user which can be converted to a UID via pwd.getpwnam. (type: str )
ReturnsThe integer UID corresponding to the given string. (type: int )
RaisesValueErrorIf the user name is supplied and pwd is not available.
def gidFromString(gidString): (source)
Convert a group identifier, as a string, into an integer GID.
ParametersuidA string giving the base-ten representation of a GID or the name of a group which can be converted to a GID via grp.getgrnam. (type: str )
ReturnsThe integer GID corresponding to the given string. (type: int )
RaisesValueErrorIf the group name is supplied and grp is not available.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 15:57:47.