Package tdi :: Module util
[frames] | no frames]

Module util

source code

Misc utilities.


Author: André Malo

Classes
  Version
Represents the package version
  Deprecator
Deprecation proxy class
  CallableDeprecator
Callable proxy deprecation class
Functions
tuple
parse_content_type(value)
Parse a content type
source code
list
find_public(space)
Determine all public names in space
source code
property
Property(func)
Property with improved docs handling
source code
callable
decorating(decorated, extra=None)
Create decorator for designating decorators.
source code
any
load_dotted(name)
Load a dotted name
source code
tuple
make_dotted(name)
Generate a dotted module
source code
Variables
  __package__ = 'tdi'
Function Details

parse_content_type(value)

source code 
Parse a content type
Parameters:
  • value (basestring) - The value to parse - must be ascii compatible
Returns: tuple
The parsed header ((value, {key, [value, value, ...]})) or None

Warning: comments are not recognized (yet?)

find_public(space)

source code 
Determine all public names in space
Parameters:
  • space (dict) - Name space to inspect
Returns: list
List of public names

Property(func)

source code 
Property with improved docs handling
Parameters:
  • func (callable) - The function providing the property parameters. It takes no arguments as returns a dict containing the keyword arguments to be defined for property. The documentation is taken out the function by default, but can be overridden in the returned dict.
Returns: property
The requested property

decorating(decorated, extra=None)

source code 
Create decorator for designating decorators.
Parameters:
  • decorated (function) - Function to decorate
  • extra (dict) - Dict of consumed keyword parameters (not existing in the originally decorated function), mapping to their defaults. If omitted or None, no extra keyword parameters are consumed. The arguments must be consumed by the actual decorator function.
Returns: callable
Decorator

load_dotted(name)

source code 

Load a dotted name

The dotted name can be anything, which is passively resolvable (i.e. without the invocation of a class to get their attributes or the like). For example, name could be 'tdi.util.load_dotted' and would return this very function. It's assumed that the first part of the name is always is a module.

Parameters:
  • name (str) - The dotted name to load
Returns: any
The loaded object
Raises:
  • ImportError - A module in the path could not be loaded

make_dotted(name)

source code 
Generate a dotted module
Parameters:
  • name (str) - Fully qualified module name (like tdi.util)
Returns: tuple
The module object of the last part and the information whether the last part was newly added ((module, bool))
Raises:
  • ImportError - The module name was horribly invalid

Variables Details

__package__

Value:
'tdi'