Package Products :: Package ZenUtils :: Module Version :: Class Version |
[hide private]
[frames] | no frames]

# Class Version

source code

    object --+
             |
            Version

Known Subclasses:
  - ZenModel.ZenPack.Version

A class for obtaining and manipulating version numbers as well as creating the necessary version files Zenoss utilizes.

    >>> v1 = Version('Zenoss', 0, 22)
    >>> v2 = Version('Zenoss', 0, 23, 4)
    >>> v3 = Version('Zenoss', 0, 23, 7)
    >>> v4 = Version('Zenoss', 1)
    >>> v5 = Version('Zenoss', 1, 0, 2)
    >>> v6 = Version('Zenoss', 1, 0, 2)
    >>> v7 = Version('Zenoss', 1, 0, 2, 15729)
    >>> v8 = Version('Zenoss', 1, 0, 2, 15730)
    >>> v9 = Version('Zenoss', 1, 0, 3, 15729)

# test the display methods >>> v9.short() '1.0.3' >>> v9.long() 'Zenoss 1.0.3' >>> v9.full() 'Zenoss 1.0.3 r15729' >>> v2.tuple() (0, 23, 4)

# comparisons >>> v1 > v2 False >>> v3 > v2 True >>> v4 < v3 False >>> v4 > v5 False >>> v6 > v5 False >>> v6 >= v5 True >>> v6 == v5 True

# comparison, one with a revision number >>> v7 > v6 False

# revision number comparisons >>> v7 > v8 False >>> v8 > v9 False

# comparing non-Version objects with Version objects >>> '1.0.4' > v5 True >>> (1,0,1) > v5 False >>> 1 == v4 True >>> v4 == 1.0 True >>> '1.0' == v4 True

# comment/additional info >>> v10 = v9 >>> v10.setComment('A super-secret squirrel release') >>> v10.full() 'Zenoss 1.0.3 r15729 (A super-secret squirrel release)'

Instance Methods | [hide private]
__init__(self, name, major=0, minor=0, micro=0, revision=0, comment='') | source code
short(self) Returns a string of just the version number. | source code
long(self) Returns a string with the software name and the version. | source code
full(self) Returns a string with the software name, the version number, and the subversion revision number, if defined. | source code
tuple(self) Return a version tuple. | source code
incrMajor(self) | source code
incrMinor(self) | source code
incrMicro(self) | source code
setComment(self, comment) | source code
__cmp__(self, other) Comparse one verion to another. | source code
_formatSVNRevision(self) | source code
__repr__(self) | source code
__str__(self) | source code

Class Methods | [hide private]
parse(cls, versionString) Parse the version info from a string. | source code

Method Details | [hide private]

### __init__(self, name, major=0, minor=0, micro=0, revision=0, comment='') (Constructor) | source code
Overrides: object.__init__ (inherited documentation)

### __cmp__(self, other) (Comparison operator) | source code
Comparse one verion to another. If the other version supplied is not a Version instance, attempt coercion. The assumption here is that any non-Version object being compared to a Version object represents a verion of the same product with the same name but a different version number.

### __repr__(self) (Representation operator) | source code
Overrides: object.__repr__ (inherited documentation)

### __str__(self) (Informal representation operator) | source code
Overrides: object.__str__ (inherited documentation)

### parse(cls, versionString) Class Method | source code
    Parse the version info from a string. This method is usable without
    having instantiated Version, and returns an instantiation.

    The expected form is the following:
        software_name W.X.Y rZ
    where W, X, and Y represent the major, minor, and micro version numbers
    and Z is the subversion revision number.

    Only the software name is required.

    The version number is expected to have at least a major version number.
    Minor and micro version numbers are optional, but if they are provided,
    they must be dot-delimited.

    Here are some example usages:

    >>> v = Version.parse('Zenoss')
    >>> repr(v)
    'Version(Zenoss, 0, 0, 0,)'
    >>> print v
    [Zenoss, version 0.0.0]

    >>> v = Version.parse('Zenoss 1')
    >>> repr(v)
    'Version(Zenoss, 1, 0, 0,)'
    >>> print v
    [Zenoss, version 1.0.0]

    >>> v = Version.parse('Zenoss 0.26.4')
    >>> repr(v)
    'Version(Zenoss, 0, 26, 4,)'
    >>> print v
    [Zenoss, version 0.26.4]

    >>> v = Version.parse('Zenoss 0.32.1 r13667')
    >>> repr(v)
    'Version(Zenoss, 0, 32, 1, r13667)'
    >>> print v
    [Zenoss, version 0.32.1 r13667]