squirrel.catalog

Package Contents

Classes

Catalog

A dictionary-like data structure that versions and maintains Sources.

CatalogKey

Defines a key in a catalog consisting of the identifier and the version of a source.

Source

Defines a data source by describing its metadata and how it can be read.

class squirrel.catalog.Catalog

Bases: MutableMapping

A dictionary-like data structure that versions and maintains Sources.

Each source in a Catalog is stored with a squirrel.catalog.CatalogKey, which is unique.

It is possible to combine multiple Catalogs together or find the difference between them. Refer to class methods for more information.

A Catalog can be [de-]serialized. You can check out the from_xxx() and to_xxx() methods for additional information.

__contains__(identifier: str | CatalogKey | tuple[str, int])bool
__delitem__(identifier: str | CatalogKey | tuple[str, int])None
__eq__(other: Any)bool

Return self==value.

__getitem__(identifier: str | CatalogKey | tuple[str, int])CatalogSource
__iter__()Iterator[tuple[str, squirrel.catalog.source.Source]]
__len__()int
__repr__()str

Return repr(self).

__setitem__(identifier: str | CatalogKey | tuple[str, int], value: squirrel.catalog.source.Source)None
copy()Catalog

Return a deep copy of catalog

difference(other: Catalog)Catalog

Return a Catalog which consists of the difference of the input Catalogs.

filter(predicate: Callable[[CatalogSource], bool])Catalog

Filter catalog sources based on a predicate.

static from_dirs(paths: list[str])Catalog

Create a Catalog based on a list of folders containing yaml files.

static from_files(paths: list[str])Catalog

Create a Catalog based on a list of paths to yaml files.

static from_plugins()Catalog

Returns a Catalog containing sources specified by plugins.

static from_str(cat: str)Catalog

Create a Catalog based on a yaml string.

intersection(other: Catalog)Catalog

Return a Catalog which consists of the intersection of the input Catalogs.

items()Iterator[tuple[str, squirrel.catalog.source.Source]]

D.items() -> a set-like object providing a view on D’s items

join(other: Catalog)Catalog

Return a joined Catalog out of two disjoint Catalogs.

keys()KeysView[str]

D.keys() -> a set-like object providing a view on D’s keys

slice(keys: list[str])Catalog

Return a deep copy of catalog were only by key specified sources get copied.

property sourcesdict[str, CatalogSource]

Read only property

to_file(path: str)None

Save a Catalog to a yaml file at the specified path.

union(other: Catalog)Catalog

Return a Catalog which consists of the union of the input Catalogs.

class squirrel.catalog.CatalogKey

Bases: NamedTuple

Defines a key in a catalog consisting of the identifier and the version of a source.

A CatalogKey uniquely describes a Source in a Catalog.

identifier :str
version :int
classmethod from_yaml(constructor: ruamel.yaml.Constructor, node: ruamel.yaml.SequenceNode)CatalogKey

Deserializes object from SequenceNode.

classmethod to_yaml(representer: ruamel.yaml.Representer, obj: CatalogKey)ruamel.yaml.SequenceNode

Serializes object to SequenceNode.

class squirrel.catalog.Source

Defines a data source by describing its metadata and how it can be read.

The driver specified within the Source is responsible for reading from the data source and should contain all the necessary logic for reading, Source itself does not contain this logic.

Sources can be set in a Catalog along with a key and a version that uniquely identify them.

driver_kwargs :Optional[Dict[str, str]]
driver_name :str
metadata :Optional[Dict[str, str]]
__repr__()str

Return repr(self).