Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
distutils.version.LooseVersion Class Reference
Inheritance diagram for distutils.version.LooseVersion:
Inheritance graph
[legend]
Collaboration diagram for distutils.version.LooseVersion:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def parse
def __str__
def __repr__
def __eq__
def __ne__
def __lt__
def __le__
def __gt__
def __ge__

Public Attributes

 vstring
 version

Static Public Attributes

tuple component_re = re.compile(r'(\d+ | [a-z]+ | \.)', re.VERBOSE)

Private Member Functions

def _cmp

Detailed Description

Version numbering for anarchists and software realists.
Implements the standard interface for version number classes as
described above.  A version number consists of a series of numbers,
separated by either periods or strings of letters.  When comparing
version numbers, the numeric components will be compared
numerically, and the alphabetic components lexically.  The following
are all valid version numbers, in no particular order:

    1.5.1
    1.5.2b2
    161
    3.10a
    8.02
    3.4j
    1996.07.12
    3.2.pl0
    3.1.1.6
    2g6
    11g
    0.960923
    2.2beta29
    1.13++
    5.5.kw
    2.0b1pl0

In fact, there is no such thing as an invalid version number under
this scheme; the rules for comparison are simple and predictable,
but may not always give the results you want (for some definition
of "want").

Definition at line 273 of file version.py.


Constructor & Destructor Documentation

def distutils.version.LooseVersion.__init__ (   self,
  vstring = None 
)

Reimplemented from distutils.version.Version.

Definition at line 308 of file version.py.

00308 
00309     def __init__ (self, vstring=None):
00310         if vstring:
00311             self.parse(vstring)
00312 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

def distutils.version.Version.__eq__ (   self,
  other 
) [inherited]

Definition at line 45 of file version.py.

00045 
00046     def __eq__(self, other):
00047         c = self._cmp(other)
00048         if c is NotImplemented:
00049             return c
00050         return c == 0

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.version.Version.__ge__ (   self,
  other 
) [inherited]

Definition at line 75 of file version.py.

00075 
00076     def __ge__(self, other):
00077         c = self._cmp(other)
00078         if c is NotImplemented:
00079             return c
00080         return c >= 0
00081 
00082 
00083 # Interface for version-number classes -- must be implemented
00084 # by the following classes (the concrete ones -- Version should
00085 # be treated as an abstract class).
00086 #    __init__ (string) - create and take same action as 'parse'
00087 #                        (string parameter is optional)
00088 #    parse (string)    - convert a string representation to whatever
00089 #                        internal representation is appropriate for
00090 #                        this style of version numbering
00091 #    __str__ (self)    - convert back to a string; should be very similar
00092 #                        (if not identical to) the string supplied to parse
00093 #    __repr__ (self)   - generate Python code to recreate
00094 #                        the instance
00095 #    _cmp (self, other) - compare two version numbers ('other' may
00096 #                        be an unparsed version string, or another
00097 #                        instance of your version class)
00098 

Here is the call graph for this function:

def distutils.version.Version.__gt__ (   self,
  other 
) [inherited]

Definition at line 69 of file version.py.

00069 
00070     def __gt__(self, other):
00071         c = self._cmp(other)
00072         if c is NotImplemented:
00073             return c
00074         return c > 0

Here is the call graph for this function:

def distutils.version.Version.__le__ (   self,
  other 
) [inherited]

Definition at line 63 of file version.py.

00063 
00064     def __le__(self, other):
00065         c = self._cmp(other)
00066         if c is NotImplemented:
00067             return c
00068         return c <= 0

Here is the call graph for this function:

def distutils.version.Version.__lt__ (   self,
  other 
) [inherited]

Definition at line 57 of file version.py.

00057 
00058     def __lt__(self, other):
00059         c = self._cmp(other)
00060         if c is NotImplemented:
00061             return c
00062         return c < 0

Here is the call graph for this function:

def distutils.version.Version.__ne__ (   self,
  other 
) [inherited]

Definition at line 51 of file version.py.

00051 
00052     def __ne__(self, other):
00053         c = self._cmp(other)
00054         if c is NotImplemented:
00055             return c
00056         return c != 0

Here is the call graph for this function:

def distutils.version.LooseVersion.__repr__ (   self)

Reimplemented from distutils.version.Version.

Definition at line 333 of file version.py.

00333 
00334     def __repr__ (self):
00335         return "LooseVersion ('%s')" % str(self)
00336 

def distutils.version.LooseVersion.__str__ (   self)

Definition at line 329 of file version.py.

00329 
00330     def __str__ (self):
00331         return self.vstring
00332 

def distutils.version.LooseVersion._cmp (   self,
  other 
) [private]

Definition at line 337 of file version.py.

00337 
00338     def _cmp (self, other):
00339         if isinstance(other, str):
00340             other = LooseVersion(other)
00341 
00342         if self.version == other.version:
00343             return 0
00344         if self.version < other.version:
00345             return -1
00346         if self.version > other.version:
00347             return 1
00348 
00349 
00350 # end class LooseVersion

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.version.LooseVersion.parse (   self,
  vstring 
)

Definition at line 313 of file version.py.

00313 
00314     def parse (self, vstring):
00315         # I've given up on thinking I can reconstruct the version string
00316         # from the parsed tuple -- so I just store the string here for
00317         # use by __str__
00318         self.vstring = vstring
00319         components = [x for x in self.component_re.split(vstring)
00320                               if x and x != '.']
00321         for i, obj in enumerate(components):
00322             try:
00323                 components[i] = int(obj)
00324             except ValueError:
00325                 pass
00326 
00327         self.version = components
00328 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tuple distutils.version.LooseVersion.component_re = re.compile(r'(\d+ | [a-z]+ | \.)', re.VERBOSE) [static]

Definition at line 306 of file version.py.

Definition at line 326 of file version.py.

distutils.version.LooseVersion.vstring

Definition at line 317 of file version.py.


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