Skip to main content

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.

Project description

AwesomeVersion

codecov python version dependencies PyPI Actions

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.

Make anything a version object, and compare against a vast section of other version formats.

Installation

python3 -m pip install awesomeversion

AwesomeVersion class

The AwesomeVersion class takes a version as the first argument, you can also pass in additional arguments to customize the version object.

Argument Description
version The version string to parse.
ensure_strategy Match the AwesomeVersion object against spesific strategies when creating if. If it does not match AwesomeVersionStrategyException will be raised
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.

Example usage

These are some examples of what you can do, more examples can be found in the tests directory.

from awesomeversion import AwesomeVersion

current = AwesomeVersion("1.2.2")
upstream = AwesomeVersion("1.2.3")

print(upstream > current)
> True
from awesomeversion import AwesomeVersion

version = AwesomeVersion("1.2.3b0")

print(version.beta)
> True
from awesomeversion import AwesomeVersion

current = AwesomeVersion("2021.1.0")
upstream = AwesomeVersion("2021.1.0b2")

print(upstream > current)
> False
from awesomeversion import AwesomeVersion

current = AwesomeVersion("latest")
upstream = AwesomeVersion("2021.1.0")

print(upstream > current)
> False
from awesomeversion import AwesomeVersion

current = AwesomeVersion("latest")
upstream = AwesomeVersion("dev")

print(upstream > current)
> True
from awesomeversion import AwesomeVersion

with AwesomeVersion("20.12.0") as current:
    with AwesomeVersion("20.12.1") as upstream:
        print(upstream > current)
> True
from awesomeversion import AwesomeVersion

with AwesomeVersion("20.12.0") as current:
    print("2020.12.1" > current)
> True
from awesomeversion import AwesomeVersion

version = AwesomeVersion("2.12.0")
print(version.major)
> 2
print(version.minor)
> 12
print(version.patch)
> 0

Contribute

All contributions are welcome!

  1. Fork the repository
  2. Clone the repository locally and open the devcontainer or use GitHub codespaces
  3. Do your changes
  4. Lint the files with make lint
  5. Ensure all tests passes with make test
  6. Ensure 100% coverage with make coverage
  7. Commit your work, and push it to GitHub
  8. Create a PR against the main branch

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awesomeversion-22.5.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

awesomeversion-22.5.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file awesomeversion-22.5.1.tar.gz.

File metadata

  • Download URL: awesomeversion-22.5.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.4 Linux/5.13.0-1022-azure

File hashes

Hashes for awesomeversion-22.5.1.tar.gz
Algorithm Hash digest
SHA256 84bcd85ab1bb9a287cfd1b2e5145f888b6e02ef3e3a63a07453f10f2f6e50fe3
MD5 6b2b493912cb7737d665b4415aea8e96
BLAKE2b-256 59802de22db5a7becd3fc23ede195e4323f2643a0e990166e632864d635348a3

See more details on using hashes here.

File details

Details for the file awesomeversion-22.5.1-py3-none-any.whl.

File metadata

  • Download URL: awesomeversion-22.5.1-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.4 Linux/5.13.0-1022-azure

File hashes

Hashes for awesomeversion-22.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d4f110a62228e323ee2df5f0c700b3c047507c8fd8e7a39602ecbd8b4743ea62
MD5 ed753fed131ad4ee60cae420e11531a1
BLAKE2b-256 ce4ee638ef2d897622243cbed53634ad40ea4370cd3e876df03c4e2df29da7c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page