omero.util.metadata_utils module

Utilities for manipulating bulk-annotations

Includes classes to help with basic data-munging (TODO), and for formatting data for clients.

class util.metadata_utils.BulkAnnotationConfiguration(default_cfg, column_cfgs)[source]

Bases: object

Parent class for handling bulk-annotation column configurations

GROUPREQUIRED = {'columns', 'namespace'}
OPTIONAL = {'clientname', 'clientvalue', 'include', 'includeclient', 'omitempty', 'position', 'split', 'type', 'visible'}
REQUIRED = {'name'}
get_column_config(cfg)[source]

Replace unspecified fields in a column config with defaults If this is a group return a GroupConfig object

static get_default_cfg(cfg)[source]

Get the default column configuration, fill in unspecified fields

classmethod validate_column_config(cfg)[source]

Check whether a column config section is valid, throws Exception if not

classmethod validate_filled_column_config(cfg)[source]

Check whether a column config section is valid after filling all optional fields with defaults

classmethod validate_group_config(cfg)[source]

Check whether a group config section is valid, throws Exception if not Not recursive (doesn’t check columns for validity)

class util.metadata_utils.GroupConfig(namespace, column_cfg)[source]

Bases: object

class util.metadata_utils.KeyValueGroupList(headers, default_cfg, column_cfgs)[source]

Bases: BulkAnnotationConfiguration

Converts bulk-annotation rows into key-value lists

get_group_output_configs(column_cfgs, isdefault)[source]

Get the full set of output column configs for a single group, taking into account specified column positions and columns included/excluded according to the defaults:

  • positioned columns are at the specified index (1-based)

  • gaps between positioned columns are filled with unpositioned columns in order of - Configured but unpositioned columns - Unconfigured columns in order of headers (assuming the default config is for them to be included)

  • If there are gaps and no remaining columns to be included raise an exception

get_output_configs()[source]

Get the full set of output column configs including column groups The default set of column configs has an empty namespace

get_transformers()[source]

Return a set of KeyValueListTransformer objects, one for each group

class util.metadata_utils.KeyValueListPassThrough(headers, default_cfg=None, column_cfgs=None)[source]

Bases: object

Converts bulk-annotation rows into key-value lists without any transformation

transform(rowvalues)[source]

Pass through a table row unchanged :param values: A table rows :return: A row in the form [(k1, v1), (k2, v2), …]

class util.metadata_utils.KeyValueListTransformer(headers, output_configs, name=None)[source]

Bases: object

Converts bulk-annotation rows into key-value lists

transform(rowvalues)[source]

Transform a table row :param rowvalues: A table row :return: The transformed rows in the form [(k1, v1), (k2, v2), …]. v* will be a list of length: - 1 in most cases - 0 if omitempty=True and value was empty - 1+ if split option is enabled

static transform1(value, cfg)[source]

Process a single value corresponding to a single table row-column

Returns:

The key and a list of [value]. In general [values] will be a single item unless split is specified in cfg in which case there may be multiple.