Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timbo-rafa/version
A version comparator
https://github.com/timbo-rafa/version
challenges comparators demo executable nosetests operator-overloading pypi python-module python-package python3 test
Last synced: about 1 month ago
JSON representation
A version comparator
- Host: GitHub
- URL: https://github.com/timbo-rafa/version
- Owner: timbo-rafa
- License: mit
- Created: 2020-02-15T21:24:09.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-15T22:24:56.000Z (almost 5 years ago)
- Last Synced: 2024-04-28T19:21:43.805Z (8 months ago)
- Topics: challenges, comparators, demo, executable, nosetests, operator-overloading, pypi, python-module, python-package, python3, test
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Version
A version is a string that matches the following regex:
```python
"^v?(\d+)(?:.(\d+))?(?:.(\d+))?(?:-?(a|b|rc)(\d+)?)?$"
```
E.g. v0.11.22-rc3.#### Assumptions
1. v1 is equivalent to v1.0.0
2. A version without a candidate is greater than its candidate counterpart
e.g. v2 > v2rc > v2b > v2a## Installation
```
pip install rtimbo-version
```## Usage
```python
>>> from version import Version
>>> v1 = Version("v0.2.11rc3")
>>> v1.major
0
>>> v1.minor
2
>>> v1.patch
11
>>> v1.candidate
'rc'
>>> v1.candidate_number
3
>>> v1 > 0
True
>>> v1 > 1
False
``````python
>>> available_versions = [
... Version("v0.9.2b"),
... Version("v0.9.1"),
... Version("v0.9.2"),
... Version("v2.9.3rc1"),
... Version("3.0.0"),
... Version("v0.9.2a1"),
... Version("v0.9.2rc1"),
... Version("1.0.0"),
... Version("2.5.7"),
... Version("v0.9.2rc3")]
>>>
>>> print('\n'.join([str(version) for version in sorted(available_versions)]))
v0.9.1
v0.9.2a1
v0.9.2b0
v0.9.2rc1
v0.9.2rc3
v0.9.2
v1.0.0
v2.5.7
v2.9.3rc1
v3.0.0```