anod.queries

Provides high level queries on Anod specs.

Module Contents

Classes

SourceKey

SourceClosure

Helper object to resolve source closure for a given spec instance.

Functions

get_build_node(…)

Return the build anod instance corresponding to an install.

get_source_builder(→ e3.anod.package.SourceBuilder | None)

Given a source name return the associated builder.

class anod.queries.SourceKey

Bases: NamedTuple

anod_uid: str
src_name: str
publish: bool
anod.queries.get_build_node(anod_instance: e3.anod.spec.Anod, context: e3.anod.context.AnodContext, default: None = None) e3.anod.spec.Anod | None
anod.queries.get_build_node(anod_instance: e3.anod.spec.Anod, context: e3.anod.context.AnodContext, default: e3.anod.spec.Anod) e3.anod.spec.Anod

Return the build anod instance corresponding to an install.

Parameters:
  • anod_instance – an Anod instance

  • context – Anod context

  • default – value returned if the build Anod instance does not exist

Returns:

the associated build anod instance. If such instance does not exist then return default

anod.queries.get_source_builder(anod_instance: e3.anod.spec.Anod, source_name: str, local_sources_only: bool = False) e3.anod.package.SourceBuilder | None

Given a source name return the associated builder.

Parameters:
  • anod_instance – an Anod instance

  • source_name – a source name

  • local_sources_only – if True consider only builders declared in the spec itself. if False also consider source builders in source dependencies (i.e: require=’source_pkg’)

Returns:

a source builder or None if no builder can be found.

class anod.queries.SourceClosure(anod_instance: e3.anod.spec.Anod, context: e3.anod.context.AnodContext, expand_packages: bool = False, data_key: collections.abc.Callable[[Any], str] | None = None)

Helper object to resolve source closure for a given spec instance.

compute_closure(spec: e3.anod.spec.Anod, publish: bool) None

Compute the source closure (internal function).

Parameters:
  • spec – an anod instance to inspect

  • publish – whether the sources found should be marked internal or not.

resolve_package(spec_uid: str, data: list[tuple[Any, bool]]) None

Associate source information to a given package.

Parameters:
  • spec_uid – the anod uid

  • data – list of data associated to the package. This is a list of tuples (src_data, publish). Where src_data is the data for a given source package and publish a boolean indicated whether the entry is internal or not.

resolve_source(source_name: str, data: Any) None

Associate source information to a given source.

Parameters:
  • source_name – the source name. The closure resolution is done locally so we can assume that for all occurences of a given source name the same data should be associated

  • data – data associated with the source

get_source_list() list[list[Any]]

Get the closure source list.

The function return the list of data for the sources in the closure.

Note that if a package present in the closure is both marked as untracked and that closure cannot be found then it is ignored. For any other source or package if no data is associated then an assert exception will be raised

Returns:

a list of list (source, publish)