utils Package¶
utils Package¶
environment Module¶
Get special directory path
- maidenhair.utils.environment.get_system_root_directory()[source]¶
Get system root directory (application installed root directory)
Returns: string :
A full path
- maidenhair.utils.environment.get_system_plugins_directory()[source]¶
Get system plugin directory (plugin directory for system wide use)
Returns: string :
A full path
peakset Module¶
- maidenhair.utils.peakset.find_peakset(dataset, basecolumn=-1, method='', where=None)[source]¶
Find peakset from the dataset
Parameters: dataset : list
A list of data
basecolumn : int
An index of column for finding peaks
method : str
A method name of numpy for finding peaks
where : function
A function which recieve data and return numpy indexing list
Returns: list :
A list of peaks of each axis (list)
plugins Module¶
A plugin registry module
- class maidenhair.utils.plugins.Registry[source]¶
Bases: object
A registry class which store plugin objects
Methods
find(name[, namespace]) Find plugin object load_plugins([plugin_dirs, quiet]) Load plugins in sys.path and plugin_dirs register(name, obj[, namespace]) Register obj as name in namespace - ENTRY_POINT = 'maidenhair.plugins'¶
- find(name, namespace=None)[source]¶
Find plugin object
Parameters: name : string
A name of the object entry or full namespace
namespace : string, optional
A period separated namespace. E.g. foo.bar.hogehoge
Returns: instance :
An instance found
Raises: KeyError :
If the named instance have not registered
Examples
>>> registry = Registry() >>> registry.register('hello', 'goodbye') >>> registry.register('foo', 'bar', 'hoge.hoge.hoge') >>> registry.register('foobar', 'foobar', 'hoge.hoge') >>> registry.find('hello') == 'goodbye' True >>> registry.find('foo', 'hoge.hoge.hoge') == 'bar' True >>> registry.find('hoge.hoge.foobar') == 'foobar' True
- load_plugins(plugin_dirs=None, quiet=True)[source]¶
Load plugins in sys.path and plugin_dirs
Parameters: plugin_dirs : list or tuple of string, optional
A list or tuple of plugin directory path
quiet : bool, optional
If True, print all error message
- register(name, obj, namespace=None)[source]¶
Register obj as name in namespace
Parameters: name : string
A name of the object entry
obj : instance
A python object which will be registered
namespace : string, optional
A period separated namespace. E.g. foo.bar.hogehoge
Examples
>>> registry = Registry() >>> registry.register('hello', 'goodbye') >>> registry.raw.hello == 'goodbye' True >>> registry.register('foo', 'bar', 'hoge.hoge.hoge') >>> isinstance(registry.raw.hoge, Bunch) True >>> isinstance(registry.raw.hoge.hoge, Bunch) True >>> isinstance(registry.raw.hoge.hoge.hoge, Bunch) True >>> registry.raw.hoge.hoge.hoge.foo == 'bar' True >>> registry.register('hoge.hoge.foobar', 'foobar') >>> registry.raw.hoge.hoge.hoge.foo == 'bar' True >>> registry.raw.hoge.hoge.foobar == 'foobar' True
rglob Module¶
Recursive glob module
This glob is a recursive version of glob module.
- maidenhair.utils.rglob.iglob(pathname)[source]¶
Return an iterator which yields the same values as glob() without actually storing them all simultaneously.
Parameters: pathname : string
A glob pattern string which will be used for finding files
Returns: iterator :
An iterator instance which will yield full path name