1# AwesomeVersion 2 3[![codecov](https://codecov.io/gh/ludeeus/awesomeversion/branch/main/graph/badge.svg)](https://codecov.io/gh/ludeeus/awesomeversion) 4![python version](https://img.shields.io/badge/Python-3.6=><=3.11_dev-blue.svg) 5![dependencies](https://img.shields.io/badge/Dependencies-0-blue.svg) 6[![PyPI](https://img.shields.io/pypi/v/awesomeversion)](https://pypi.org/project/awesomeversion) 7![Actions](https://github.com/ludeeus/awesomeversion/workflows/Actions/badge.svg?branch=main) 8 9_One version package to rule them all, One version package to find them, One version package to bring them all, and in the darkness bind them._ 10 11Make anything a version object, and compare against a vast section of other version formats. 12 13## Installation 14 15```bash 16python3 -m pip install awesomeversion 17``` 18 19## AwesomeVersion class 20 21The AwesomeVersion class takes a version as the first argument, you can also pass in additional arguments to customize the version object. 22 23Argument | Description 24--- | --- 25`version` | The version string to parse. 26`ensure_strategy` | Match the `AwesomeVersion` object against spesific strategies when creating if. If it does not match `AwesomeVersionStrategyException` will be raised 27`find_first_match` | If True, the version given will be scanned for the first match of the given `ensure_strategy`. Raises `AwesomeVersionStrategyException` If it is not found for any of the given strategies. 28 29 30## Example usage 31 32These are some examples of what you can do, more examples can be found in the `tests` directory. 33 34```python 35from awesomeversion import AwesomeVersion 36 37current = AwesomeVersion("1.2.2") 38upstream = AwesomeVersion("1.2.3") 39 40print(upstream > current) 41> True 42``` 43 44```python 45from awesomeversion import AwesomeVersion 46 47version = AwesomeVersion("1.2.3b0") 48 49print(version.beta) 50> True 51``` 52 53```python 54from awesomeversion import AwesomeVersion 55 56current = AwesomeVersion("2021.1.0") 57upstream = AwesomeVersion("2021.1.0b2") 58 59print(upstream > current) 60> False 61``` 62 63```python 64from awesomeversion import AwesomeVersion 65 66current = AwesomeVersion("latest") 67upstream = AwesomeVersion("2021.1.0") 68 69print(upstream > current) 70> False 71``` 72 73```python 74from awesomeversion import AwesomeVersion 75 76current = AwesomeVersion("latest") 77upstream = AwesomeVersion("dev") 78 79print(upstream > current) 80> True 81``` 82 83```python 84from awesomeversion import AwesomeVersion 85 86with AwesomeVersion("20.12.0") as current: 87 with AwesomeVersion("20.12.1") as upstream: 88 print(upstream > current) 89> True 90``` 91 92```python 93from awesomeversion import AwesomeVersion 94 95with AwesomeVersion("20.12.0") as current: 96 print("2020.12.1" > current) 97> True 98``` 99 100```python 101from awesomeversion import AwesomeVersion 102 103version = AwesomeVersion("2.12.0") 104print(version.major) 105> 2 106print(version.minor) 107> 12 108print(version.patch) 109> 0 110``` 111 112## Contribute 113 114**All** contributions are welcome! 115 1161. Fork the repository 1172. Clone the repository locally and open the devcontainer or use GitHub codespaces 1183. Do your changes 1194. Lint the files with `make lint` 1205. Ensure all tests passes with `make test` 1216. Ensure 100% coverage with `make coverage` 1227. Commit your work, and push it to GitHub 1238. Create a PR against the `main` branch 124