dependency – Dependency Change Detection

dependency provides a set of tools for checking if dependencies need to be rebuilt. DependencyChecks provides a flexible interface to this dependency checking.

class dependency.DependencyChecks(check=None)
check(target, dependency)
Parameters:
  • target (path) – The path to a file to check.
  • dependency (path) – The path or list of paths of files that the target depends upon.
Returns:

True or False depending on the result of dependency check specified by _check.

check_method

Property of the current dependency checking method. Returns the string identifier of the current dependency checking method.

If set to None, reverts _check to the default value (i.e. mtime if exists it or the first available method.). Otherwise only permits setting _check to an existing method, and raises DependencyCheckError otherwise.

checks = None

A dictionary mapping the kinds of dependency checks to the functions that implement the dependency test.

force(target, dependency)
Parameters:
  • target (path) – The path to a file to check.
  • dependency (path) – The path or list of paths of files that the target depends upon.
Returns:

True always.

hash(target, dependency)
Parameters:
  • target (path) – The path to a file to check.
  • dependency (path) – The path or list of paths of files that the target depends upon.
Returns:

True when dependency or any members of a dependency list have a different md5 checkusm than target.

ignore(target, dependency)
Parameters:
  • target (path) – The path to a file to check.
  • dependency (path) – The path or list of paths of files that the target depends upon.
Returns:

False always.

mtime(target, dependency)
Parameters:
  • target (path) – The path to a file to check.
  • dependency (path) – The path or list of paths of files that the target depends upon.
Returns:

True when dependency or any members of a dependency list are newer than target.

dependency.hash_check(target, dependency)
Parameters:
  • target (path) – The path to a file to build.
  • dependency (path) – The path of a file to that the target depends upon.
Returns:

True if target and dependency have different md5 checksums as determined by md5_file_check().

dependency.md5_file_check(file, block_size=1048576)
Parameters:
  • file (path) – The path to a file.
  • blocksize (int) – The size of the block size for the hashing process. Defaults to 2**20 or 1048576.
Returns:

The md5 checkusm of file.

dependency.mtime_check(target, dependency)
Parameters:
  • target (path) – The path to a file to build.
  • dependency (path) – The path of a file to that the target depends upon.
Returns:

True if target has a larger mtime than the dependency.