Utility functions, part of the Traits project.
|Copyright:||2003-2013 Enthought, Inc.|
Defines utility functions for operating on camel case names.
Simple functor class to convert names from camel case to idiomatic Python variable names.
>>> camel2python = CamelCaseToPython >>> camel2python('XMLActor2DToSGML') 'xml_actor2d_to_sgml'
Convert a camel case string into words separated by spaces.
>>> camel_case_to_words('CamelCase') 'Camel Case'
Provides functions that mange strings to avoid characters that would be problematic in certain situations.
Munge a string to avoid characters that might be problematic as a filename in some filesystems.
Return a timestamp that has been cleansed of characters that might cause problems in filenames, namely colons. If no datetime object is provided, then uses the current time.
The timestamp is in ISO-8601 format with the following exceptions:
A string timestamp.
Attempt to make a valid Python identifier out of a name.
A decorator for marking methods/functions as deprecated.
A factory for decorators for marking methods/functions as deprecated.
Determine the user’s home directory.
Utility functions for managing and finding resources (ie. images/files etc).
get_path : Returns the absolute path of a class or instance
Returns an absolute path for the specified path.
‘path’ can be a string, class or instance.
Creates a name starting with ‘prefix’ that is not in ‘names’.
Returns a file object or file path pointing to the desired resource.
file (file object or file path) – A file object containing the resource. If return_path is True, ‘file’ will be the full path to the resource. If the file is not found or cannot be opened, None is returned.
This function will find a desired resource file and return an opened file object. The main method of finding the resource uses the pkg_resources resource_stream method, which searches your working set for the installed project specified and appends the resource_path given to the project path, leading it to the file. If setuptools is not installed or it cannot find/open the resource, find_resource will use the sys.path to find the resource if alt_path is defined.
Store the content of a resource, given by the name of the project and the path (relative to the root of the project), into a newly created file.
The first two arguments (project and resource_path) are the same as for the function find_resource in this module. The third argument (filename) is the name of the file which will be created, or overwritten if it already exists. The return value in always None.
A function to import symbols.
Import the symbol defined by the specified symbol path.
import_symbol(‘tarfile:TarFile’) -> TarFile import_symbol(‘tarfile:TarFile.open’) -> TarFile.open
To allow compatibility with old-school traits symbol names we also allow all-dotted paths, but in this case you can only import top-level names from the module.
import_symbol(‘tarfile.TarFile’) -> TarFile
A simple topological sort on a dictionary graph.
Exception for cyclic graphs.
Returns the nodes in the graph in topological order.
A Trait Documenter (Subclassed from the autodoc ClassLevelDocumenter)
|copyright:||Copyright 2012 by Enthought, Inc|
Specialized Documenter subclass for trait attributes.
The class defines a new documenter that recovers the trait definition signature of module level and class level traits.
To use the documenter, append the module path in the extension attribute of the conf.py.
Using the TraitDocumenter in conjunction with TraitsDoc is not advised.
Check that the documented member is a trait instance.
Trait attributes have no members
Never try to get a docstring from the trait.
Get the Trait object.
Code adapted from autodoc.Documenter.import_object.
Add the directive header ‘attribute’ with the annotation option set to the trait definition.
Add the TraitDocumenter in the current sphinx autodoc instance.