namespace.py¶
This module provides utilities for grouping objects into namespaces.
- hutch_python.namespace.class_namespace(cls, scope=None)¶
Create a
namespace
that contains objects of a specific type.- Parameters:
cls (
type
orstr
)scope (
module
,namespace
, orlist
of these) – Every object attached to the given modules will be considered for theclass_namespace
. Ifscope
is omitted, we’ll check all objects loaded byhutch-python
and everything in the caller’s global frame. If anything is an instance ofophyd.Device
, we’ll also include the object’s components as part of the scope, using thename
attribute to identify them rather than the attribute name on the device. This will continue recursively, skipping lazy and dynamic components.
- Returns:
namespace
- Return type:
- hutch_python.namespace.tree_namespace(scope=None)¶
Create a
namespace
that accumulates objects and creates a tree.This tree is a nested set of
IterableNamespace
objects based on the object names as defined in scope. We will split on underscores and use the splits to create the tree.- Parameters:
scope (
module
,namespace
, orlist
of these) – Every object attached to the given modules will be considered for thetree_namespace
. Ifscope
is omitted, we’ll check all objects loaded byhutch-python
and everything in the caller’s global frame.- Returns:
namespace
- Return type: