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

Type Version

object --+
         |
        Version

Known Subclasses:
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)'
Method Summary
  __init__(self, name, major, minor, micro, revision, comment)
  __cmp__(self, other)
Comparse one verion to another.
  __repr__(self)
  __str__(self)
  full(self)
Returns a string with the software name, the version number, and the subversion revision number, if defined.
  getSVNRevision(self)
  incrMajor(self)
  incrMicro(self)
  incrMinor(self)
  long(self)
Returns a string with the software name and the version.
  parse(self, versionString)
Parse the version info from a string. (Class method)
  setComment(self, comment)
  short(self)
Returns a string of just the version number.
  tuple(self)
Return a version tuple.
  _formatSVNRevision(self)
Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Instance Method Details

__cmp__(self, other)
(Comparison operator)

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.

full(self)

Returns a string with the software name, the version number, and the subversion revision number, if defined.

long(self)

Returns a string with the software name and the version.

short(self)

Returns a string of just the version number.

tuple(self)

Return a version tuple.

Class Method Details

parse(self, versionString)

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]

Generated by Epydoc 2.1 on Thu Aug 16 09:55:07 2007 http://epydoc.sf.net