Skip to main content

accepts 2 version string as input and returns whether one is greater than, equal, or less than the other

Project description

This is a software library that accepts 2 version string as input and returns whether one is greater than, equal, or less than the other. As an example: "1.2" is greater than "1.1".

REQUIREMENTS: PYTHON 3. and above

usage:

from compare_string_version import compareVersion
print(compareVersion(a,b))

expected return

when

a==b:

    a is equal to b

a>b:

    a is greater than b

a<b: 

    a is less than b

Exceptions:

either a is null and/or b is null: Value(s) can not be null: Both values must be string
either a and/or b are/is not a string: Both must be string

assumptions:

a and b are string

a and b are not null (None)

both version strings only contain numbers (0...9) and this char '.':

    123.456.789.012

    'A..Z','a..z' and any other chars like "! @ # $ % * [ } ] { ^ ç ? ; : . > , < | " will be removed from the comparison:
        some adjustment would be applied after char removal:
        '..' will be replaced by '.'
        string ending in '.' will be shorted by 1

this '..' will not be accepted as it is '.' duplicated:
        '10..12..13..14' will become '10.12.13.14'

the comparison would be from the group split by the char '.':
        10.12.13.14 would be treated as 10 12 13 14
        01.10.100.001 would be treated as 1 10 100 1

all the comparison would check the integer part of the version:
        '10.0' is equal to '010.0.0.0.0.0.0.0' because int('10.0') is equal to int ('010')

whoever version number has the higher far left group would be named as greater:
        10.0.0.0.0.1 is greater then 9.9.9.9.9.9.9
        0.1.0.0.0.0.1 is greater than 0.0.9
        the same "int" rule will be applied for any other group in the string

all '0's from the left will be disregarded if its value is '0':
        1.0.0.0 is equal to 1.0 and it is equal to 1

the following .py were used in order to test data

test997.py has generated output5.txt

test996.py has generated output4.txt

test995.py has generated output1.txt and output2.txt

test994.py has generated output3.txt

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

compare_string_version-0.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

compare_string_version-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file compare_string_version-0.1.0.tar.gz.

File metadata

  • Download URL: compare_string_version-0.1.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

File hashes

Hashes for compare_string_version-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ee2177bfe8f57520cdc76257d37adea930c5feb81befd3345090856f5640c0b0
MD5 8b1e7ecdc778a18e564f977ac14d26f0
BLAKE2b-256 a345dc14b52eedf73acfd40b7859863def834821bb73904be4a41746aea60724

See more details on using hashes here.

File details

Details for the file compare_string_version-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: compare_string_version-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

File hashes

Hashes for compare_string_version-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5876f1486535a3a0f3360334b436f871899e9d6af497c2a71d23dceb79ac4f6
MD5 7c5950a66815e0def982e655c2141e10
BLAKE2b-256 c67cdfd82618806e71cc26c7b083ffdb5ec0b78d0cda6f1e577bd3874e0b47bd

See more details on using hashes here.

Supported by

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