bidsschematools.data

Module containing data files, including the schema source files

bidsschematools.data.load_resource(*segments) Path

Load package files relative to bidsschematools.data.

This package contains the following (top-level) files/directories:

  • metaschema.json

  • schema/

Classes

class bidsschematools.data.Loader(anchor: str | ModuleType)

Bases: object

A loader for package files relative to a module

This class wraps importlib.resources to provide a getter function with an interpreter-lifetime scope. For typical packages it simply passes through filesystem paths as Path objects. For zipped distributions, it will unpack the files into a temporary directory that is cleaned up on interpreter exit.

This loader accepts a fully-qualified module name or a module object.

Expected usage:

'''Data package

.. autofunction:: load_data
'''

from bidsschematools.data import Loader

load_data = Loader(__package__)

Loader objects implement the callable() interface and generate a docstring, and are intended to be treated and documented as functions.

__call__(*segments) Path

Ensure data is available as a Path.

Any temporary files that are created remain available throughout the duration of the program, and are deleted when Python exits.

Results are cached so that multiple calls do not unpack the same data multiple times, but the cache is sensitive to the specific argument(s) passed.