| |
- VersionNumber
- VersionPattern
- VersionSpec
- exceptions.ValueError(exceptions.StandardError)
-
- VersionFormatError
class VersionNumber |
|
VersionNumber: represents a structured version number.
A VersionNumber has the form "MAJOR", "MAJOR.MINOR", or
"MAJOR.MINOR.RELEASE". MAJOR must be a positive integer (not zero).
MINOR must be a non-negative integer (zero is allowed). RELEASE,
if present, must be a string of letters, digits, plus, minus,
underscore, dot.
The version numbers "3" and "3.0" are considered equal (the
minor value is assumed to be zero if not given). However, this
is not true of the release value; "3.0" and "3.0.0" are considered
different. (This is a quirk of the version-matching algorithm, which
requires a major and minor value but ignores the release value.)
VersionNumbers are immutable, and may be used as dict keys. You can
compare them with ==, !=, <, >, and so on.
Constructors:
VersionNumber() -- default version "1.0"
VersionNumber(int) -- construct "X.0"
VersionNumber(int, int) -- construct "X.Y"
VersionNumber(int, int, val, val, ...) -- construct "X.Y.val.val..."
(the release values may be int or str)
VersionNumber(str) -- parse a string into a VersionNumber
Publicly readable fields:
major -- the major value (int)
minor -- the minor value (int)
release -- the release string (may be None)
Public methods:
match() -- compare to a VersionSpec |
|
Methods defined here:
- __cmp__(self, vers)
- __eq__(self, vers)
- __hash__(self)
- __init__(self, *args)
- __ne__(self, vers)
- __repr__(self)
- __str__(self)
- init_num(self, major, minor=None, release=())
- init_num(major, minor=None, release=())
Utility function for constructor. (Do not call.)
- init_str(self, arg)
- init_str(arg)
Utility function for constructor. (Do not call.)
- match(self, spec)
- match(spec) -> bool
Compare the version number to a VersionSpec (or to a string which
defines a VersionSpec). Return True if the version number satisfies
the spec.
|
class VersionPattern |
|
VersionPattern: represents one PATTERN element of a VersionSpec.
A VersionPattern looks like one of: "VERSION", "VERSION.", "VERSION-",
"-VERSION", "VERSION-VERSION".
A VERSION is "MAJOR" or "MAJOR.MINOR".
(This class is used internally by VersionSpec, and should be ignored
by outside callers.)
Constructors:
VersionPattern((int,int)) -- construct "X.Y"
VersionPattern((int,int), (int,int)) -- construct "X.Y-Z.W"
VersionPattern((int,int), None) -- construct "X.Y-"
VersionPattern(None, (int,int)) -- construct "-Z.W"
VersionPattern(str) -- parse a string into a VersionPattern
Public methods:
match() -- compare to a version major/minor number |
|
Methods defined here:
- __cmp__(self, other)
- __hash__(self)
- __init__(self, start, end=True)
- __str__(self)
- init_str(self, val)
- init_str(arg)
Utility function for constructor. (Do not call.)
- init_tup(self, startpair, endpair)
- init_tup(arg)
Utility function for constructor. (Do not call.)
- match(self, major, minor)
- match(major, minor) -> bool
Compare the pattern to a version number (as major and minor
values). Return True if the version number satisfies the pattern.
- parse_number(self, val)
- parse_number(val) -> (int,int)
Parse a string of the form "X" or "X.Y" into a pair of numbers.
(If there is no second number, it is assumed to be zero.)
This parsing is strict; no spaces or other extraneous characters
are allowed.
Data and other attributes defined here:
- ANDON = 3
- RANGE = 1
- SIMPLE = 0
- UPTO = 2
- typenames = {0: 'SIMPLE', 1: 'RANGE', 2: 'UPTO', 3: 'ANDON'}
|
class VersionSpec |
|
VersionSpec: represents a requirement for certain version numbers.
A VersionSpec looks like one or more PATTERNS, separated by commas.
A PATTERN looks like one of: "VERSION", "VERSION.", "VERSION-",
"-VERSION", "VERSION-VERSION".
A VERSION is "MAJOR" or "MAJOR.MINOR".
(Here a complex, but legal, VersionSpec: "-2.3,5,7.3.,9.9-10.1,13.5-")
A VersionSpec matches a version number if any of its PATTERNs match.
PATTERNs match as follows:
"X.Y" -- major version must be X, minor version must be Y or higher
"X.Y." -- major version must be X, minor version must be Y
"X.Y-" -- major version is X, minor version is Y or higher *or*
major version is higher than X
"-Z.W" -- major version is Z, minor version is W is lower *or*
major version is lower than Z
"X.Y-Z.W" -- both of the above
In all cases, the release value of the version number is ignored.
VersionSpecs are immutable, and may be used as dict keys. However,
they compare naively; they will only test as equal if they are
visually identical. The specs "1-3,3-5" and "1-5" are logically
equivalent, but they will compare unequal.
VersionSpecs cannot be compared with <, >, <=, >=.
Constructors:
VersionSpec() -- default spec "1.0-"; this matches anything
VersionSpec(int) -- construct "X.0"
VersionSpec(int, int) -- construct "X.Y"
VersionSpec(str) -- parse a string into a VersionSpec
Note that when parsing a string, extraneous characters are firmly
rejected. Do not put spaces in your comma-separated list.
Public methods:
match() -- compare to a VersionNumber |
|
Methods defined here:
- __eq__(self, vers)
- __hash__(self)
- __init__(self, *args)
- __ne__(self, vers)
- __repr__(self)
- __str__(self)
- init_num(self, major, minor=None)
- init_num(major, minor=None)
Utility function for constructor. (Do not call.)
- init_str(self, arg)
- init_str(arg)
Utility function for constructor. (Do not call.)
- match(self, vnum)
- match(vnum) -> bool
Compare the version spec to a VersionNumber (or to a string or
int which defines a VersionNumber). Return True if the version
number satisfies the spec.
| |