Skip to content

lc_resolver

LcCatalogResolver

Bases: object

The resolver maintains a collection of resources, and translates semantic origins into physical archives. The Catalog supplies a request and a level requirement It also acts as a factory for those resources, so when a request is provided, it is answered with a live archive.

Then the Catalog turns that into a static archive and keeps a list of it. The catalog also keeps a separate list of foreground foregrounds (which are not static; which contain fragments). These can be converted into static archives by turning the fragments into processes.

This file could probably be re-thought, especially in the era of resources delivered via web. For now, we will monkeypatch.

origins property

Generates pairs: origin, list of supported interfaces

Returns:

Type Description

add_resource(resource, store=True)

Add a resource to the resolver's list. By default, save the resource permanently as a file in resources dir.

Parameters:

Name Type Description Default
resource
required
store

[True] if False, add the resource to memory only

True

Returns:

Type Description

delete_origin(origin)

remove all resources for a given origin.

Parameters:

Name Type Description Default
origin
required

Returns:

Type Description

get_resource(ref=None, iface=None, source=None, strict=True, include_internal=True)

The purpose of this function is to allow a user to retrieve a resource by providing enough information to identify it uniquely. If strict is True (default), then parameters are matched exactly and more than one match raises an exception. If strict is False, then origins are matched approximately and the first (lowest-priority) match is returned.

The convention is that no two resources should have the same source, so if a source is provided then the output of resources_with_source() is used. Otherwise, the output of resolve() is used. Internal resources (indexes and archives) are never returned. [WHY?]

Returns:

Type Description

a single LcResource

resolve(req, interfaces=None, strict=False)

Fuzzy resolver returns all resources that match the request and have equal or greater specificity. 'uslci.clean' will match queries for 'uslci' but not for 'uslci.original' or 'uslci.clean.allocated'. However, 'uslci.clean.allocated' will match a query for 'uslci.clean'

Parameters:

Name Type Description Default
req
required
interfaces

could be a single interface specification or a list

None
strict

[False] if true, only yields interface for which req matches ref

False

Returns:

Type Description