esrf_pathlib._schemas.registry#

Functions

get_schema_registry([fallback_depth])

Classes

ParsedPath(registry, concept_values[, template])

Container of path concept values which are either provided by the users or extracted from a path string by a schema registry.

PathSchemaRegistry(schemas)

Use one or more path schemas to find the best matching path template for a path string or a dictionary of path concepts.

class esrf_pathlib._schemas.registry.ParsedPath(registry, concept_values, template=None)[source]#

Bases: object

Container of path concept values which are either provided by the users or extracted from a path string by a schema registry. The corresponding path template is provided or can be derived using the registry.

Fields are exposed as instance attributes. A field can be a path concept, derived concept or rendered path template.

Parameters:
field_names(include_missing=False)[source]#

Return all field names. A field is either a path concept, derived path concept or a path template.

Parameters:

include_missing (bool)

Return type:

List[str]

field_values(include_missing=False)[source]#

Return all fields that can be derived from the known concepts. Use “*” for missing concepts.

Parameters:

include_missing (bool)

Return type:

Dict[str, Any]

get_field_value(item, raise_on_missing=True, raise_on_mismatch=True)[source]#
Raises:
Parameters:
  • item (str)

  • raise_on_missing (bool)

  • raise_on_mismatch (bool)

Return type:

Any

nonpath_field_names(include_missing=False)[source]#

Return all field names that are not paths (path concepts and derived path concepts).

Parameters:

include_missing (bool)

Return type:

List[str]

path_field_names()[source]#

Return all field names that are paths (path templates).

Return type:

List[str]

render(template_name=None)[source]#

Convert schema to path.

Raises:
Parameters:

template_name (Optional[str])

Return type:

str

replace_concepts(template_name=None, **concept_values)[source]#

Returns a new ParsedPath instance with additional or replaces concepts.

Raises:
Parameters:
Return type:

ParsedPath

strip_mount_point()[source]#

Returns a new ParsedPath instance with stripped leading segments.

Raises:
Return type:

ParsedPath

property concept_names: List[str]#
property required_concept_names: List[str]#
property schema_identifier: SchemaIdentifier#
property template: PathTemplate#
Raises:
property template_name: str#
class esrf_pathlib._schemas.registry.PathSchemaRegistry(schemas)[source]#

Bases: object

Use one or more path schemas to find the best matching path template for a path string or a dictionary of path concepts. With the template path strings are parsed to a dictionary of concept values (wrapped by a ParsedPath class). Inversally a dictionary of concept values can be rendered as a path string.

Parameters:

schemas (List[BasePathSchema])

concept_names(schema_identifier=None)[source]#
Parameters:

schema_identifier (Optional[SchemaIdentifier])

Return type:

List[str]

derived_concept_names(schema_identifier=None)[source]#
Parameters:

schema_identifier (Optional[SchemaIdentifier])

Return type:

List[str]

get_concept(name, schema_identifier=None)[source]#
Raises:

UnknownPathConcept

Parameters:
Return type:

PathConcept

get_derived_concept(name, schema_identifier=None)[source]#
Raises:

UnknownPathConcept

Parameters:
Return type:

DerivedConcept

get_template(name, schema_identifier=None)[source]#
Raises:

UnknownPathTemplate

Parameters:
Return type:

PathTemplate

parse_path(path)[source]#
Raises:

PathSchemaMatchError

Parameters:

path (Union[str, Path])

Return type:

ParsedPath

render_path(concept_values, template_name=None, schema_identifier=None)[source]#
Raises:
Parameters:
Return type:

str

template_names(schema_identifier=None)[source]#
Parameters:

schema_identifier (Optional[SchemaIdentifier])

Return type:

List[str]

property name: str#
esrf_pathlib._schemas.registry.get_schema_registry(fallback_depth=None, **schemas)[source]#
Raises:
Parameters:
  • fallback_depth (Optional[int])

  • schemas (Optional[int])

Return type:

PathSchemaRegistry