# Version Parser
## JavaScript Version
[https://www.npmjs.com/package/version-parser](https://www.npmjs.com/package/version-parser)
[![npm version](https://badge.fury.io/js/version-parser.svg)](https://badge.fury.io/js/version-parser)
## Python Version
[![Build Status](https://travis-ci.org/eieste/VersionParser.svg?branch=master)](https://travis-ci.org/eieste/VersionParser)
[![PyPI version](https://badge.fury.io/py/version-parser.svg)](https://badge.fury.io/py/version-parser)
The version parser is able to parse versions and figure out which of them are build in
one of the following three formats: Major-Version, Minor-Version and Build-Version.
Possible input types are:
| Version | Typ |
|----------|-------------------|
| v1.2.3 | Version |
| V1.2.3 | Version |
| v_1_2_3 | FILENAME |
| v1_2_3 | FILENAME |
| V_1_2_3 | FILENAME |
| V1_2_3 | FILENAME |
| 1_2_3 | FILENAME |
| VM1m2b3 | CLASSNAME_BUILD |
| VM1m2p3 | CLASSNAME_PATCH |
| vM1m2b3 | CLASSNAME_BUILD |
| vM1m2p3 | CLASSNAME_PATCH |
| 1.2.3 | STRIPPED_VERSION |
| 2312 | NUMBER |
## Install
```python
pip install version-parser
```
## Usage
Create object with the version as a String as initial parameter.
```python
from version_parser import Version
v1 = Version("v2.3.4")
```
To compare two version objects/numbers, simply put the versions as Strings into
seperate objects and compare them using the logical operators.
```python
from version_parser.version import Version
v1 = Version("v2.3.4")
v2 = Version("v2.3.2")
print(v1 < v2)
>> False
print(v1 > v2)
>> True
print(v1 == v2)
>> False
```
The last digets behind the last dot should be the Patch or Build Version Number.
Differences in this area should be compatible to each other.
```python
from version_parser.version import Version
v1 = Version("v2.3.4")
v2 = Version("v2.3.5")
print(v1 == v2)
>> False
print(v1.compatible_version_with(v2))
>> True
```
You can also get only the Major, Minor or Build Version by using:
````python
from version_parser import Version
v = Version("v2.3.4")
v.get_major_version()
2
v.get_minor_version()
3
v.get_build_version()
4
````
It's possible to convert the version format, too:
````python
from version_parser import Version, VersionType
v = Version("v2.3.4") # VersionType = Version
print(v.get_type())
>> VersionType.Version
print(v.get_typed_version(VersionType.FILENAME))
>> v_2_3_4
````
Any version can be represented by an Integer.
> The sections of major, minor, build/patched version should have a maximum of three digets.
````python
from version_parser import Version
v = Version("v2.3.4")
print(v.get_number())
>> 2003004
````
## VersionTypes
### VersionType.FILENAME
```python
"v_<MAJOR>_<MINOR>_<BUILD/PATCH>"
```
### VersionType.CLASSNAME
```python
"VM<MAJOR>m<MINOR>b<BUILD/PATCH>"
```
### VersionType.VERSION
```python
"v<MAJOR>.<MINOR>.<BUILD/PATCH>"
```
### VersionType.STRIPPED_VERSION
```python
"<MAJOR>.<MINOR>.<BUILD/PATCH>"
```
### VersionType.NUMBER
> each section is filled zeros up to three digets
```python
"<MAJOR><MINOR><BUILD/PATCH>"
```
### VersionType.CLASSNAME_BUILD
> same like CLASSNAME_BUILD
### VersionType.CLASSNAME_PATCH
```python
"VM<MAJOR>m<MINOR>p<BUILD/PATCH>"
^
PATCH
```
Raw data
{
"_id": null,
"home_page": "https://github.com/eieste/VersionParser",
"name": "version-parser",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Stefan Eiermann",
"author_email": "python-org@ultraapp.de",
"download_url": "https://files.pythonhosted.org/packages/b9/18/61a661be6225176a05ce1cad4f1bcfc9cba57744a9faacf550c5a9e68070/version_parser-1.0.1.tar.gz",
"platform": "",
"description": "# Version Parser\n\n\n## JavaScript Version\n\n[https://www.npmjs.com/package/version-parser](https://www.npmjs.com/package/version-parser)\n\n[![npm version](https://badge.fury.io/js/version-parser.svg)](https://badge.fury.io/js/version-parser)\n\n## Python Version\n\n[![Build Status](https://travis-ci.org/eieste/VersionParser.svg?branch=master)](https://travis-ci.org/eieste/VersionParser)\n[![PyPI version](https://badge.fury.io/py/version-parser.svg)](https://badge.fury.io/py/version-parser)\n\nThe version parser is able to parse versions and figure out which of them are build in\none of the following three formats: Major-Version, Minor-Version and Build-Version.\n\nPossible input types are:\n\n| Version | Typ |\n|----------|-------------------|\n| v1.2.3 | Version |\n| V1.2.3 | Version |\n| v_1_2_3 | FILENAME |\n| v1_2_3 | FILENAME |\n| V_1_2_3 | FILENAME |\n| V1_2_3 | FILENAME |\n| 1_2_3 | FILENAME |\n| VM1m2b3 | CLASSNAME_BUILD |\n| VM1m2p3 | CLASSNAME_PATCH |\n| vM1m2b3 | CLASSNAME_BUILD |\n| vM1m2p3 | CLASSNAME_PATCH |\n| 1.2.3 | STRIPPED_VERSION |\n| 2312 | NUMBER |\n\n\n## Install\n```python\npip install version-parser\n```\n\n## Usage\n\nCreate object with the version as a String as initial parameter.\n\n```python\nfrom version_parser import Version\n\n\nv1 = Version(\"v2.3.4\")\n```\n\n\nTo compare two version objects/numbers, simply put the versions as Strings into \nseperate objects and compare them using the logical operators.\n```python\nfrom version_parser.version import Version\n\n\nv1 = Version(\"v2.3.4\")\nv2 = Version(\"v2.3.2\")\n\nprint(v1 < v2)\n>> False\n\n\nprint(v1 > v2)\n>> True\n\n\nprint(v1 == v2)\n>> False\n\n```\n\n\nThe last digets behind the last dot should be the Patch or Build Version Number.\nDifferences in this area should be compatible to each other.\n```python\nfrom version_parser.version import Version\n\n\nv1 = Version(\"v2.3.4\")\nv2 = Version(\"v2.3.5\")\n\n\nprint(v1 == v2)\n>> False\n\n\nprint(v1.compatible_version_with(v2))\n>> True\n\n```\n\nYou can also get only the Major, Minor or Build Version by using:\n\n````python\nfrom version_parser import Version\nv = Version(\"v2.3.4\")\n\nv.get_major_version()\n2\nv.get_minor_version()\n3\nv.get_build_version()\n4\n````\n\nIt's possible to convert the version format, too:\n\n````python\nfrom version_parser import Version, VersionType\nv = Version(\"v2.3.4\") # VersionType = Version\nprint(v.get_type())\n>> VersionType.Version\n\nprint(v.get_typed_version(VersionType.FILENAME))\n>> v_2_3_4\n````\n\nAny version can be represented by an Integer.\n> The sections of major, minor, build/patched version should have a maximum of three digets.\n\n````python\nfrom version_parser import Version\nv = Version(\"v2.3.4\")\nprint(v.get_number())\n>> 2003004\n````\n\n\n## VersionTypes\n\n### VersionType.FILENAME\n```python\n\"v_<MAJOR>_<MINOR>_<BUILD/PATCH>\"\n```\n\n### VersionType.CLASSNAME\n```python\n\"VM<MAJOR>m<MINOR>b<BUILD/PATCH>\"\n```\n\n### VersionType.VERSION\n```python\n\"v<MAJOR>.<MINOR>.<BUILD/PATCH>\"\n```\n\n### VersionType.STRIPPED_VERSION\n```python\n\"<MAJOR>.<MINOR>.<BUILD/PATCH>\"\n```\n\n### VersionType.NUMBER\n> each section is filled zeros up to three digets\n```python\n\"<MAJOR><MINOR><BUILD/PATCH>\"\n```\n\n### VersionType.CLASSNAME_BUILD\n> same like CLASSNAME_BUILD \n\n\n### VersionType.CLASSNAME_PATCH\n```python\n\"VM<MAJOR>m<MINOR>p<BUILD/PATCH>\"\n ^\n PATCH \n```",
"bugtrack_url": null,
"license": "",
"summary": "This package can parse and compare semantic versioning.",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/eieste/VersionParser"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b91861a661be6225176a05ce1cad4f1bcfc9cba57744a9faacf550c5a9e68070",
"md5": "0e8aa09a0e3834ae1c82d9f1f18500d6",
"sha256": "7320b00cab8a04694206818c9129864dd0783cec0c0eff25b1c922e7d838dbc0"
},
"downloads": -1,
"filename": "version_parser-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "0e8aa09a0e3834ae1c82d9f1f18500d6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4357,
"upload_time": "2021-01-06T16:33:05",
"upload_time_iso_8601": "2021-01-06T16:33:05.526828Z",
"url": "https://files.pythonhosted.org/packages/b9/18/61a661be6225176a05ce1cad4f1bcfc9cba57744a9faacf550c5a9e68070/version_parser-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-01-06 16:33:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "eieste",
"github_project": "VersionParser",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "version-parser"
}