Home | Trees | Indices | Help |
---|
|
|
|||
CLIargsError Arguments were not passed in correctly. |
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
Simple meta-decorator that makes decorators preserve the attributes of the modified function. Stolen from innumerable online recipes, but most directly from http://wiki.python.org/moin/PythonDecoratorLibrary. |
Decorator that parses Meant for functions that are a target of setuptools' automatic script
creation (by default, nothing is passed in, and the function must handle
sys.argv parsing itself). If something very simple is all that is
required, this is the answer. Fancier arguments should use
If the wrong args/kwargs are passed in such that a TypeError is raised, the docstring is printed, so that's an ideal place to put usage information.
|
Factory for a decorator that redirects sys.stdout to a given file-like
object during function execution. Thus, >>> from StringIO import StringIO >>> logfile = StringIO() >>> logger = redirect(logfile) >>> @logger ... def func(): ... print "ABCDEFGHIJK" ... >>> func() >>> logfile.seek(0) >>> logfile.read().strip() 'ABCDEFGHIJK' |
Factory for decorator that ensures the decorated function is run in a specified directory, then changes back to original directory. >>> import tempfile >>> realpath = os.path.realpath >>> new, cur = map(realpath, (tempfile.mkdtemp(), os.curdir)) >>> @indir(new) ... def whereami(): ... return realpath(os.curdir) ... >>> whereami() == new True >>> realpath(os.curdir) == cur True |
Provided for backwards compatibility with pre-0.1.3. Will be removed in 0.1.5. |
Provided for backwards compatibility with pre-0.1.3. Will be removed in 0.1.5. |
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Sat Oct 4 00:23:29 2008 | http://epydoc.sourceforge.net |