PEP-440 version parsing, interpretation and manipulation
Project description
pepver
PEP-440 version parsing, interpretation and manipulation.
>>> from pepver import Version
>>> version = Version.parse("0!1.2.3.4a5.post6.dev7+8.9")
>>> version.epoch
0
>>> version.release
(1, 2, 3, 4)
>>> version.major
1
>>> version.minor
2
>>> version.micro
3
>>> version.pre
('a', 5)
>>> version.post
6
>>> version.dev
7
>>> version.local
'8.9'
Usage
The main star of the library is the Version
class, which encompasses the semantics of a version string.
It can be instantiated directly or be parsed from a string:
>>> from pepver import Version
>>> Version(1, 2, 3, 4)
Value(release=(1,), pre=2, post=3, dev=4)
>>> Version((0, 1, 2, 3), post=11, epoch=1)
Value(epoch=1, release=(0, 1, 2, 3), post=11)
>>> Version.parse("11.2")
Value(release=(11, 2))
Versions can be updated to suit one's needs:
>>> from pepver import Version
>>> version = Version.parse("0!1.2.3.4a5.post6.dev7+8.9")
>>> version.update("minor")
Value(epoch=0, release=(1, 3))
>>> version.update("post", -2)
Value(epoch=0, release=(1, 2, 3, 4), pre=('a', 5), post=4)
>>> version.update("release")
Value(epoch=0, release=(1, 2, 3, 5))
>>> version.update("release").is_final()
True
Versions correctly convert into strings. Note that the conversion is "normalized" ie standard representation that is the same for the same version:
>>> from pepver import Version
>>> str(Version.parse("010.12-11"))
'10.12.post11'
>>> str(Version.parse("1.2.3preview11dev"))
'1.2.3rc11.dev0'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pepver-1.0.1.tar.gz
(6.6 kB
view hashes)
Built Distribution
pepver-1.0.1-py3-none-any.whl
(6.3 kB
view hashes)