hashdist.spec.profile — HashDist Profiles

Not supported:

  • Diamond inheritance
class hashdist.spec.profile.FileResolver(checkouts_manager, search_dirs)

Find spec files in an overlay-based filesystem, consulting many search paths in order. Supports the <repo_name>/some/path-convention.

Methods

find_file(filenames)

Search for a file.

Search for a file with the given filename/path relative to the root of each of self.search_dirs.

Parameters:

filenames : list of strings

Filenames to seach for. The entire list will be searched before moving on to the next layer/overlay.

Returns:

Returns the found file (in the :

``<repo_name>/some/path``-convention), or None if no file was :

found. :

glob_files(patterns, match_basename=False)

Match file globs.

Like find_file, but uses a set of patterns and tries to match each pattern against the filesystem using glob.glob.

Parameters:

patterns : list of strings

Glob patterns

match_basename : boolean

If match_basename is set, only the basename of the file is compared (i.e., one file with each basename will be returned).

Returns:

The result is a dict mapping the “matched name” to a pair :

(pattern, full qualified path). :

* The matched name is a path relative to root of overlay :

(required to be unique) or just the basename, depending on match_basename.

* The pattern returned is the pattern that whose match gave :

rise to the “matched path” key.

* The full qualified name is the filename that was mattched by :

the pattern.

class hashdist.spec.profile.PackageYAML(used_name, filename, parameters, in_directory)

Holds content of a package yaml file

The content is unmodified except for {{VAR}} variable expansion.

Attributes

doc dict The deserialized yaml source
in_directory boolean Whether the yaml file is in its private package directory that may contain other files.
parameters dict of str Parameters with the defaults from the package yaml file applied
filename str Full qualified name of the package yaml file
hook_filename str or None Full qualified name of the package .py hook file, if it exists.
dirname

Name of the package directory.

Returns:

String, full qualified name of the directory containing the :

yaml file. :

Raises:

A ``ValueError`` is raised if the package is a stand-alone :

yaml file, that is, there is no package directory. :

class hashdist.spec.profile.Profile(logger, doc, checkouts_manager)

Profiles acts as nodes in a tree, with extends containing the parent profiles (which are child nodes in a DAG).

Methods

find_package_file(pkgname, filename)

Find a package resource file.

Search for the file at:

  • $pkgs/filename,
  • $pkgs/pkgname/filename,

in this order.

Parameters:

pkgname : string

Name of the package (excluding .yaml).

filename : string

File name to look for.

Returns:

The full qualifiedfilename as a string, or ``None`` if no file :

is found. :

load_package_yaml(pkgname, parameters)

Search for the yaml source and load it.

Load the source for pkgname (after substitution by a use: profile section, if any) from either

  • $pkgs/pkgname.yaml,
  • $pkgs/pkgname/pkgname.yaml, or
  • $pkgs/pkgname/pkgname-*.yaml

by searching through the paths in the package_dirs: profile setting. The paths are searched order, and only the first match per basename is used. That is, $pkgs/foo/foo.yaml overrides $pkgs/foo.yaml. And $pkgs/foo/foo-bar.yaml is returned in addition.

In case of many matches, any when’-clause is evaluated on parameters and a single document should result, otherwise an exception is raised. A document without a when-clause is overridden by those with a when-clause.

Parameters:

pkgname : string

Name of the package (excluding .yaml).

parameters : dict

The profile parameters.

Returns:

A :class:`PackageYAML` instance if successfull. :

Raises:

* class:`~hashdist.spec.exceptions.ProfileError`` is raised if :

there is no such package.

* class:`~hashdist.spec.exceptions.PackageError`` is raised if :

a package conflicts with a previous one.

resolve(path)

Turn <repo>/path into /tmp/foo-342/path

class hashdist.spec.profile.TemporarySourceCheckouts(source_cache)

A context that holds a number of sources checked out to temporary directories until it is released.

Methods

resolve(path)

Expand path-names of the form <repo_name>/foo/bar, replacing the <repo_name> part (where repo_name is given to checkout, and the < and > are literals) with the temporary checkout of the given directory.

hashdist.spec.profile.load_and_inherit_profile(checkouts, include_doc, cwd=None, override_parameters=None)

Loads a Profile given an include document fragment, e.g.:

file: ../foo/profile.yaml

or:

file: linux/profile.yaml
urls: [git://github.com/hashdist/hashstack.git]
key: git:5aeba2c06ed1458ae4dc5d2c56bcf7092827347e

The load happens recursively, including fetching any remote dependencies, and merging the result into this document.

cwd is where to interpret file in include_doc relative to (if it is not in a temporary checked out source). It can use the format of TemporarySourceCheckouts, <repo_name>/some/path.