Metadata-Version: 2.0
Name: version-filter
Version: 0.4.0
Summary: A semantic and regex version filtering/masking library.
Home-page: https://github.com/dropseedlabs/version-filter
Author: Dropseed
Author-email: python@dropseed.io
License: MIT license
Keywords: version_filter
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Requires-Dist: semantic-version (==2.6.0)

==============
version-filter
==============


.. image:: https://travis-ci.org/dropseedlabs/version-filter.svg?branch=master
        :target: https://travis-ci.org/dropseedlabs/version-filter

.. image:: https://img.shields.io/pypi/v/version_filter.svg
        :target: https://pypi.python.org/pypi/version_filter

.. image:: https://img.shields.io/pypi/l/version_filter.svg
        :target: https://pypi.python.org/pypi/version_filter

.. image:: https://img.shields.io/pypi/pyversions/version_filter.svg
        :target: https://pypi.python.org/pypi/version_filter


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 substitution character in the mask for the major, minor and patch components where you want
to limit the version filter to just those versions where it has the same value as the given current_version.  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``.  It can be used in the
major, minor, patch or pre-release components of version'

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 greater than the currently installed version, but in the same
  major release
* ``'L.L.Y'`` # return only those patch versions that are greater than the currently installed version, but in the same
  major and minor release
* ``'Y.Y.Y'`` # return all major, minor and patch versions
* ``'Y.Y.Y-Y'`` # return all major, minor, patch and prerelease versions
* ``'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
* ``'*'`` # return all versions, including pre-releases

List of version strings
~~~~~~~~~~~~~~~~~~~~~~~

The list of version strings is expected to be a set of well formed semantic versions conforming to the SemVer v2 spec.

Current Version
~~~~~~~~~~~~~~~

A version string that conforms to the SemVer v2 spec.

Usage
-----

.. code-block:: python

    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
---------

* `Semver Specification <http://semver.org//>`_
* `NPM Semver Spec <https://semver.npmjs.com/>`_
* `Yarn <https://yarnpkg.com/lang/en/docs/dependency-versions/>`_
* `Dependencies.io Docs <http://dependencies-public.netlify.com/docs/>`_

License
-------
* Free software: MIT license

Credits
-------
* Paul Ortman
* Dave Gaeddert


=======
History
=======

0.4.0 (2017-06-30)
------------------

- Do two-staging parsing of version strings to be more accurate and robust
- Fix a couple of documentation bugs with the package name vs project name


0.3.0 (2017-05-30)
------------------

- Accept (but ignore) version strings with leading 'v' or '=' characters


0.2.0 (2017-05-24)
------------------

- Add support for pre-release versions


0.1.1 (2017-05-23)
------------------

- Fix some documentation


0.1.0 (2017-05-20)
------------------

* First release on PyPI.


