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

tuple VERSION_RE

Properties

 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:
    Version(1,2,3,'4.5alpha6')
or by giving the composite version string, like:
    Version(version="1.2.3-4.5alpha6").

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 wikiutil.py.


Member Function Documentation

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

Definition at line 2584 of file wikiutil.py.

02584 
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 wikiutil.py.

02595 
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
02601 
def MoinMoin.wikiutil.Version.parse_version (   cls,
  version 
)

Definition at line 2577 of file wikiutil.py.

02577 
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:
re.compile(
        r"""(?P<major>\d+)    \.    (?P<minor>\d+)    \.    (?P<release>\d+)    (-     (?P<additional>.+)    )?""",
            re.VERBOSE)

Definition at line 2565 of file wikiutil.py.


Property Documentation

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

Definition at line 2593 of file wikiutil.py.

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

Definition at line 2590 of file wikiutil.py.

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

Definition at line 2591 of file wikiutil.py.

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

Definition at line 2592 of file wikiutil.py.


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