Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Attributes | Properties
MoinMoin.wikiutil.Version Class Reference

List of all members.

Public Member Functions

def parse_version
def __new__
def __str__

Static Public Attributes



 major = property(lambda self: self[0])
 minor = property(lambda self: self[1])
 release = property(lambda self: self[2])
 additional = property(lambda self: self[3])

Detailed Description

Version objects store versions like 1.2.3-4.5alpha6 in a structured
way and support version comparisons and direct version component access.
1: major version (digits only)
2: minor version (digits only)
3: (maintenance) release version (digits only)
4.5alpha6: optional additional version specification (str)

You can create a Version instance either by giving the components, like:
or by giving the composite version string, like:

Version subclasses tuple, so comparisons to tuples should work.
Also, we inherit all the comparison logic from tuple base class.

Definition at line 2548 of file

Member Function Documentation

def MoinMoin.wikiutil.Version.__new__ (   cls,
  major = 0,
  minor = 0,
  release = 0,
  additional = '',
  version = None 

Definition at line 2584 of file

02585     def __new__(cls, major=0, minor=0, release=0, additional='', version=None):
02586         if version:
02587             major, minor, release, additional = cls.parse_version(version)
02588         return tuple.__new__(cls, (major, minor, release, additional))

Definition at line 2595 of file

02596     def __str__(self):
02597         version_str = "%d.%d.%d" % (self.major, self.minor, self.release)
02598         if self.additional:
02599             version_str += "-%s" % self.additional
02600         return version_str
def MoinMoin.wikiutil.Version.parse_version (   cls,

Definition at line 2577 of file

02578     def parse_version(cls, version):
02579         match = cls.VERSION_RE.match(version)
02580         if match is None:
02581             raise ValueError("Unexpected version string format: %r" % version)
02582         v = match.groupdict()
02583         return int(v['major']), int(v['minor']), int(v['release']), str(v['additional'] or '')

Member Data Documentation

Initial value:
        r"""(?P<major>\d+)    \.    (?P<minor>\d+)    \.    (?P<release>\d+)    (-     (?P<additional>.+)    )?""",

Definition at line 2565 of file

Property Documentation

MoinMoin.wikiutil.Version.additional = property(lambda self: self[3]) [static]

Definition at line 2593 of file

MoinMoin.wikiutil.Version.major = property(lambda self: self[0]) [static]

Definition at line 2590 of file

MoinMoin.wikiutil.Version.minor = property(lambda self: self[1]) [static]

Definition at line 2591 of file

MoinMoin.wikiutil.Version.release = property(lambda self: self[2]) [static]

Definition at line 2592 of file

The documentation for this class was generated from the following file: