DirectoryVersionScanner

class chango.concrete.DirectoryVersionScanner(base_directory, unreleased_directory, directory_pattern=re.compile('(?P<uid>[^_]+)_(?P<date>[\\d-]+)'))

Bases: VersionScanner

Implementation of a version scanner that assumes that change notes are stored in subdirectories named after the version identifier.

Parameters:
  • base_directory (str | Path) –

    The base directory to scan for version directories.

    Important

    If the path is relative, it will be resolved relative to the directory of the calling module.

    Example

    If you build your DirectoryVersionScanner within /home/user/project/chango.py, passing base_directory="changes" will resolve to /home/user/project/changes.

  • unreleased_directory (str | Path) –

    The directory that contains unreleased changes.

    Important

    If pathlib.Path.is_dir() returns False for this directory, it will be assumed to be a subdirectory of the base_directory.

  • directory_pattern (str | re.Pattern, optional) – The pattern to match version directories against. Must contain one named group uid for the version identifier and a second named group for the date for the date of the version release in ISO format.

base_directory

The base directory to scan for version directories.

Type:

Path

directory_pattern

The pattern to match version directories against.

Type:

re.Pattern

unreleased_directory

The directory that contains unreleased changes.

Type:

Path

get_available_versions(start_from=None, end_at=None)

Implementation of chango.abc.VersionScanner.get_available_versions().

Important

Limiting the version range by start_from and end_at is based on lexicographical comparison of the version identifiers.

Returns:

The available versions within the specified range.

Return type:

Tuple[Version]

get_latest_version()

Implementation of chango.abc.VersionScanner.get_latest_version().

Important

In case of multiple releases on the same day, lexicographical comparison of the version identifiers is employed.

Returns:

The latest version

Return type:

Version

has_unreleased_changes()

Implementation of chango.abc.VersionScanner.has_unreleased_changes(). Checks if unreleased_directory contains any files.

Returns:

True if there are unreleased changes, False otherwise.

Return type:

bool