esrf_pathlib._schemas.registry#
Functions
|
Classes
|
Container of path concept values which are either provided by the users or extracted from a path string by a schema registry. |
|
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:
objectContainer 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:
registry (
PathSchemaRegistry)concept_values (
Dict[str,Union[str,date,DataType,TomoResultType,None]])template (
Optional[PathTemplate])
- 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
ParsedPathinstance with additional or replaces concepts.- Raises:
- Parameters:
template_name (
Optional[str])concept_values (
Union[str,date,DataType,TomoResultType,None])
- Return type:
- strip_mount_point()[source]#
Returns a new
ParsedPathinstance with stripped leading segments.- Raises:
- Return type:
- 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:
objectUse 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
ParsedPathclass). 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:
- Parameters:
name (
str)schema_identifier (
Optional[SchemaIdentifier])
- Return type:
- get_derived_concept(name, schema_identifier=None)[source]#
- Raises:
- Parameters:
name (
str)schema_identifier (
Optional[SchemaIdentifier])
- Return type:
- get_template(name, schema_identifier=None)[source]#
- Raises:
- Parameters:
name (
str)schema_identifier (
Optional[SchemaIdentifier])
- Return type:
- render_path(concept_values, template_name=None, schema_identifier=None)[source]#
- Raises:
- Parameters:
concept_values (
Dict[str,Union[str,date,DataType,TomoResultType,None]])template_name (
Optional[str])schema_identifier (
Optional[SchemaIdentifier])
- Return type:
str
- template_names(schema_identifier=None)[source]#
- Parameters:
schema_identifier (
Optional[SchemaIdentifier])- Return type:
List[str]
- property name: str#