unified-range
The library converts input semver ranges to a uniform model, and the other way around, providing objects that are easier to use programmatically.
Examples of supported ranges
- npm style semver -
<1.2.3 >=2.0.0 - ruby style semver -
<1.2.3, >=2.0.0 - maven style version ranges -
[1.2.3,2.1.1), [3.0.0,4.1.1)
Additionally, use this library to run algorithms on any input version ranges and calculate whether a specific version is included in this range.
Prerequisites
-
Ensure you have installed either pip or pipenv
-
Install:
pipenv install unified-rangeorpip install unified-range -
Import the
apimodule:from unified_range import api
How to use
Following are the different functions you can perform with this library.
To convert a range to the uniform string range, from the semver format:
ver_rng = api.from_semver(semver_str)
Results: uniform range structure
Convert from the uniform range structure to a semver string (return str):
semver = api.to_semver(unified_spec_str)
To convert the versionrange object to a string:
version_range_str = str(ver_rng)
Convert from the uniform string to the uniform model object (VersionRange objects):
ver_rng = api.unified_range(unified_spec_str)
>>> api.unified_range('[1.2.3,4.5.6)')
<unified_range.models.UnifiedVersionRange at 0x7f7e4dc17320>
Within a list of ranges, retrieve versions not included:
filtered_lst = api.filter_versions(ascending_version_list, ranges)
>>> api.filter_versions(['0.1', '0.2', '1.0', '1.1', '2.0'], ['[,0.2]', '[1.1]'])
['1.0', '2.0']
The versions in ascending_version_list should be sorted in ascending order,
from oldest to newest, and contain all the versions for the package.
From a list of version ranges, retrieve the closest version in the list to the current version (next):
Filter next version and maximum version from list of version and ranges:
next_version = api.next_filtered_version(current_version, ascending_version_list, ranges)
current_version must be included in the ascending_version_list.
>>> api.next_filtered_version(current_version='0.2', ascending_version_list=['0.1', '0.2', '1.0', '1.1', '2.0'], ranges=['[,0.2]', '[1.1]'])
'1.0'
>>> api.next_filtered_version(current_version='1.1', ascending_version_list=['0.1', '0.2', '1.0', '1.1', '2.0'], ranges=['[,0.2]', '[1.1]'])
'2.0'
Retreive the latest version that is not included:
max_version = api.maximum_filtered_version(ascending_version_list, ranges)
>>> api.maximum_filtered_version(ascending_version_list=['0.1', '0.2', '1.0', '1.1', '2.0'], ranges=['[,0.2]', '[1.1]'])
'2.0'
Uniform structure examples
Following are the uniform structures used in this library:
Uniform string structure example: (,1.2.3)
Uniform model examples:
UnifiedVersionRange.constraints -> List[Restrictions]
Restriction.bounds -> Tuple[Bound, Bound]
Bound.version -> str
Bound.inclusive -> boolean
References and prior works
This library was built with the following:
- Maven’s VersionRange: model and spec of maven.
- https://semver.org/
- npm’s semver library
Metadata
Release files for unified-range 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| unified-range-0.1.1.tar.gz | 8.8 kB | Without provenance | Details for unified-range-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| unified_range-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for unified_range-0.1.1-py3-none-any.whl |
Total release size: 17.5 kB
Release files / unified-range-0.1.1.tar.gz
| Download URL | unified-range-0.1.1.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a1bbe0cb5c1a9a4d90d6ea35a55b594b7f6d6c669c79fd31d34570c5670a6d9
|
|
BLAKE2b-256 checksum How to use checksums |
1e383341a020274a63e9094f5e389f010e28a5576deef9dffd4bb861c6a1c363
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.9.9 Linux/4.15.0-1115-aws
|
Release files / unified_range-0.1.1-py3-none-any.whl
| Download URL | unified_range-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
34fa642ad9da081367958d3fb8a5f3794c72d76132e4d7f880f4be3e643a38dc
|
|
BLAKE2b-256 checksum How to use checksums |
148aaaea1d2d4f5c1a2c3f03563f17cbfc3648a54c2193c02d2fee24170400d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.9.9 Linux/4.15.0-1115-aws
|
Security for unified-range 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.