bidsschematools.utils¶
Utility functions for the bids-specification schema.
Classes
- class bidsschematools.utils.WarningsFilter(*filters: tuple[Literal['default', 'error', 'ignore', 'always', 'all', 'module', 'once']])¶
Bases:
objectContext manager to apply warning filters.
Arguments are lists of positional arguments to
warnings.filterwarnings().
Functions
- bidsschematools.utils.configure_logger(lgr: Logger) None¶
Configuring formatting and stream handler for the logger.
Should not be used when bidsschematools is used as a library.
- Parameters:
lgr (logging.Logger)
- bidsschematools.utils.get_bundled_schema_path() str¶
Get the path to the schema directory.
- Returns:
Absolute path to the directory containing schema-related files.
- Return type:
- bidsschematools.utils.get_logger(name: str | None = None, level: int | str | None = None) Logger¶
Return a logger to use.
- Parameters:
- Returns:
logger object.
- Return type:
- bidsschematools.utils.in_context(context_manager: AbstractContextManager) Callable[[Callable], Callable]¶
Convert a context manager into a function decorator.
- Parameters:
context_manager (context manager) – The context manager to use.
- Returns:
The function decorator.
- Return type:
Callable
- bidsschematools.utils.jsonschema_validator(schema: dict[str, Any], *, check_format: bool, default_cls: type[object] | None = None) object¶
Create a jsonschema validator appropriate for validating instances against a given JSON schema
- Parameters:
schema (dict[str, Any]) – The JSON schema to validate against
check_format (bool) – Indicates whether to check the format against format specifications in the schema
default_cls (type[JsonschemaValidator] or None, optional) – The default JSON schema validator class to use to create the validator should the appropriate validator class cannot be determined based on the schema (by assessing the $schema property). If None, the class representing the latest JSON schema draft supported by the jsonschema package
- Returns:
The JSON schema validator
- Return type:
JsonschemaValidator
- Raises:
jsonschema.exceptions.SchemaError – If the JSON schema is invalid