Back to index

python3.2  3.2.2
Classes | Functions | Variables
distutils.versionpredicate Namespace Reference

Classes

class  VersionPredicate

Functions

def splitUp
def split_provision

Variables

tuple re_validPackage
tuple re_paren = re.compile(r"^\s*\((.*)\)\s*$")
tuple re_splitComparison = re.compile(r"^\s*(<=|>=|<|>|!=|==)\s*([^\s,]+)\s*$")
dictionary compmap
 _provision_rx = None

Detailed Description

Module for parsing and testing package version predicate strings.

Function Documentation

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'))

Definition at line 143 of file versionpredicate.py.

00143 
00144 def split_provision(value):
00145     """Return the name and optional version number of a provision.
00146 
00147     The version number, if given, will be returned as a `StrictVersion`
00148     instance, otherwise it will be `None`.
00149 
00150     >>> split_provision('mypkg')
00151     ('mypkg', None)
00152     >>> split_provision(' mypkg( 1.2 ) ')
00153     ('mypkg', StrictVersion ('1.2'))
00154     """
00155     global _provision_rx
00156     if _provision_rx is None:
00157         _provision_rx = re.compile(
00158             "([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(?:\s*\(\s*([^)\s]+)\s*\))?$",
00159             re.ASCII)
00160     value = value.strip()
00161     m = _provision_rx.match(value)
00162     if not m:
00163         raise ValueError("illegal provides specification: %r" % value)
00164     ver = m.group(2) or None
00165     if ver:
00166         ver = distutils.version.StrictVersion(ver)
00167     return m.group(1), ver

Here is the call graph for this function:

Here is the caller graph for this function:

Parse a single version comparison.

Return (comparison string, StrictVersion)

Definition at line 17 of file versionpredicate.py.

00017 
00018 def splitUp(pred):
00019     """Parse a single version comparison.
00020 
00021     Return (comparison string, StrictVersion)
00022     """
00023     res = re_splitComparison.match(pred)
00024     if not res:
00025         raise ValueError("bad package restriction syntax: %r" % pred)
00026     comp, verStr = res.groups()
00027     return (comp, distutils.version.StrictVersion(verStr))


Variable Documentation

Definition at line 141 of file versionpredicate.py.

Initial value:
00001 {"<": operator.lt, "<=": operator.le, "==": operator.eq,
00002            ">": operator.gt, ">=": operator.ge, "!=": operator.ne}

Definition at line 28 of file versionpredicate.py.

tuple distutils.versionpredicate.re_paren = re.compile(r"^\s*\((.*)\)\s*$")

Definition at line 12 of file versionpredicate.py.

tuple distutils.versionpredicate.re_splitComparison = re.compile(r"^\s*(<=|>=|<|>|!=|==)\s*([^\s,]+)\s*$")

Definition at line 13 of file versionpredicate.py.

Initial value:
00001 re.compile(r"(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)",
00002     re.ASCII)

Definition at line 8 of file versionpredicate.py.