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 or str)

  • scope (module, namespace, or list of these) – Every object attached to the given modules will be considered for the class_namespace. If scope is omitted, we’ll check all objects loaded by hutch-python and everything in the caller’s global frame. If anything is an instance of ophyd.Device, we’ll also include the object’s components as part of the scope, using the name 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:

IterableNamespace

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, or list of these) – Every object attached to the given modules will be considered for the tree_namespace. If scope is omitted, we’ll check all objects loaded by hutch-python and everything in the caller’s global frame.

Returns:

namespace

Return type:

IterableNamespace