4Suite API Documentation: Ft.Lib.DistExt.Version

4Suite™ API Documentation

# ► Module Ft.Lib.DistExt.Version

Classes: CommonVersion, VersionPredicate |  |  |  | Functions: SplitComparison, SplitProvision

## Classes

class CommonVersion(distutils.version.Version)
  Version numbering that handles most version numbering schemes. Implements the standard interface for version number classes as described by distutils.version.Version.

      A version consists of an alternating series of release numbers followed
      by an optional series of pre-release or post-release tags. A release
      number is a series of dot-separated numeric components. Release tags are
      a series of letters optionally followed by a release number. The
      pre-release tag name is alphabetically before "final". The post-release
      tag name is alphabetically greater than or equal to "final".

      For example, "1.0b2.dev-r41475" could denote Subversion revision 41475 of
      the in-development version of the second beta of release 1.0. Notice that
      "dev" is a pre-release tag, so this version is a lower version number
      than 1.0b2, which would be the actual second beta of release 1.0. But
      the "-r41475" is a post-release tag, so this version is newer than
      "1.0b2.dev".

  ### Methods

  __cmp__(self, other)
  __str__(self)
  parse(self, vstring)

  ### Methods inherited from class distutils.version.Version

  __init__, __repr__

  ### Members

  tag_aliases = {'pr': 'c', 'pre': 'c', 'preview': 'c', 'rc': 'c'}
  tag_re = <_sre.SRE_Pattern object at 0x8253a60>
  version_re = <_sre.SRE_Pattern object at 0xb7d6d920>
class VersionPredicate
  Parse and test package version predicates.

      >>> v = VersionPredicate('pyepat.abc (>1.0, <3333.3a1, !=1555.1b3)')

      The `name` attribute provides the full dotted name that is given::

      >>> v.name
      'pyepat.abc'

      The str() of a `VersionPredicate` provides a normalized
      human-readable version of the expression::

      >>> print v
      pyepat.abc (> 1.0, < 3333.3a1, != 1555.1b3)

      The `satisfied_by()` method can be used to determine with a given
      version number is included in the set described by the version
      restrictions::

      >>> v.satisfied_by('1.1')
      True
      >>> v.satisfied_by('1.4')
      True
      >>> v.satisfied_by('1.0')
      False
      >>> v.satisfied_by('4444.4')
      False
      >>> v.satisfied_by('1555.1b3')
      False

      `VersionPredicate` is flexible in accepting extra whitespace::

      >>> v = VersionPredicate(' pat( ==  0.1  )  ')
      >>> v.name
      'pat'
      >>> v.satisfied_by('0.1')
      True
      >>> v.satisfied_by('0.2')
      False

      If any version numbers passed in do not conform to the
      restrictions of `StrictVersion`, a `ValueError` is raised::

      >>> v = VersionPredicate('p1.p2.p3.p4(>=1.0, <=1.3a1, !=1.2zb3)')
      Traceback (most recent call last):
        ...
      ValueError: invalid version number '1.2zb3'

      It the module or package name given does not conform to what's
      allowed as a legal module or package name, `ValueError` is
      raised::

      >>> v = VersionPredicate('foo-bar')
      Traceback (most recent call last):
        ...
      ValueError: expected parenthesized list: '-bar'

      >>> v = VersionPredicate('foo bar (12.21)')
      Traceback (most recent call last):
        ...
      ValueError: expected parenthesized list: 'bar (12.21)'

  ### Methods

  __init__(self, versionPredicateStr)
    Parse a version predicate string.
  __str__(self)
  satisfied_by(self, version)
    True if version is compatible with all the predicates in self. The parameter version must be acceptable to the StrictVersion constructor. It may be either a string or StrictVersion.

## Functions

SplitComparison = splitUp(pred)
  Parse a single version comparison.

      Return (comparison string, StrictVersion)

SplitProvision = split_provision(value)
  Return the name and optional version number of a provision.

      The version number, if given, will be returned as a `StrictVersion`
      instance, otherwise it will be `None`.

      >>> split_provision('mypkg')
      ('mypkg', None)
      >>> split_provision(' mypkg( 1.2 ) ')
      ('mypkg', StrictVersion ('1.2'))