Skip to main content

A semantic and regex version filtering/masking library.

Project description

version-filter

https://img.shields.io/pypi/v/version_filter.svg

A semantic and regex version filtering/masking library.

Given a filtering mask or regex and a list of versions (as strings), a subset of that list of versions will be returned. If a mask is given and the mask uses current version references, an explicit current version must also be provided as an imput must also be provided as an imput.

Inputs

Mask/Regex

The Mask can be a SemVer v2 valid mask with the following extensions.

Mask Lock Extension

Locks (L) are used as a substituion character in the mask where you want to limit the version filter to just those versions where it has the same value. If a L is present anywhere in the mask, a current_version parameter must also be provided.

Mask Yes Extension

Yes (Y) are used to provide wildcard acceptance of any value in the position of the Y.

Boolean AND and OR

Boolean AND operators (&&) and boolean OR operators (||) can be used to combine masks. However, both AND and OR cannot be combined in the same expression.

Mask Examples

Some common examples:

  • '1.Y.0' # return only those minor versions that are of major release 1

  • 'L.Y.0' # return only those minor versions that are of the currently installed version

  • 'L.L.Y' # return only those patch versions that are of the currently installed version

  • 'Y.Y.Y' # return all major, minor and patch versions (same as ‘*’)

  • 'L.L.Y || Y.Y.0' # return patch versions of my currently installed version or all major and minor releases

  • '>1.0.0 && <3.0.0' # return all versions between 1.0.0 and 3.0.0, exclusive

List of version strings

The list of version strings is expected to be a set of well formed semantic versions

Current Version

Usage

from version-filter import VersionFilter

mask = 'L.Y.Y'
versions = ['1.8.0', '1.8.1', '1.8.2', '1.9.0', '1.9.1', '1.10.0', 'nightly']
current_version = '1.9.0'

VersionFilter.semver_filter(mask, versions, current_version)
# ['1.9.1', '1.10.0']

VersionFilter.regex_filter(r'^night', versions)
# ['nightly']

Resources

License

  • Free software: MIT license

Credits

  • Paul Ortman

  • Dave Gaeddert

History

0.1.1 (2017-05-23)

  • Fix some documentation

0.1.0 (2017-05-20)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

version_filter-0.1.1.tar.gz (15.9 kB view hashes)

Uploaded Source

Built Distribution

version_filter-0.1.1-py2.py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page