• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(141)  |  Call(100)  |  Derive(0)  |  Import(41)
Convert a version string to a chronologically-sortable key

This is a rough cross between distutils' StrictVersion and LooseVersion;
if you give it versions that would work with StrictVersion, then it behaves
the same; otherwise it acts like a slightly-smarter LooseVersion. It is
*possible* to create pathological version coding schemes that will fool
this parser, but they should be very rare in practice.

The returned value will be a tuple of strings.  Numeric portions of the
version are padded to 8 digits so they will compare numerically, but
without relying on how numbers compare relative to strings.  Dots are
dropped, but dashes are retained.  Trailing zeros between alpha segments
or dashes are suppressed, so that e.g. "2.4.0" is considered the same as
"2.4". Alphanumeric parts are lower-cased.

The algorithm assumes that strings like "-" and any alpha string that
alphabetically follows "final"  represents a "patch level".  So, "2.4-1"
is assumed to be a branch or patch of "2.4", and therefore "2.4.1" is
considered newer than "2.4-1", which in turn is newer than "2.4".

Strings like "a", "b", "c", "alpha", "beta", "candidate" and so on (that
come before "final" alphabetically) are assumed to be pre-release versions,
so that the version "2.4" is considered newer than "2.4a1".

Finally, to handle miscellaneous cases, the strings "pre", "preview", and
"rc" are treated as if they were "c", i.e. as though they were release
candidates, and therefore are not as new as a version string that does not
contain them, and "dev" is replaced with an '@' so that it sorts lower than
than any other pre-release tag.

        def parse_version(s):
    """Convert a version string to a chronologically-sortable key

    This is a rough cross between distutils' StrictVersion and LooseVersion;
    if you give it versions that would work with StrictVersion, then it behaves
    the same; otherwise it acts like a slightly-smarter LooseVersion. It is
    *possible* to create pathological version coding schemes that will fool
    this parser, but they should be very rare in practice.

    The returned value will be a tuple of strings.  Numeric portions of the
    version are padded to 8 digits so they will compare numerically, but
    without relying on how numbers compare relative to strings.  Dots are
    dropped, but dashes are retained.  Trailing zeros between alpha segments
    or dashes are suppressed, so that e.g. "2.4.0" is considered the same as
    "2.4". Alphanumeric parts are lower-cased.

    The algorithm assumes that strings like "-" and any alpha string that
    alphabetically follows "final"  represents a "patch level".  So, "2.4-1"
    is assumed to be a branch or patch of "2.4", and therefore "2.4.1" is
    considered newer than "2.4-1", which in turn is newer than "2.4".

    Strings like "a", "b", "c", "alpha", "beta", "candidate" and so on (that
    come before "final" alphabetically) are assumed to be pre-release versions,
    so that the version "2.4" is considered newer than "2.4a1".

    Finally, to handle miscellaneous cases, the strings "pre", "preview", and
    "rc" are treated as if they were "c", i.e. as though they were release
    candidates, and therefore are not as new as a version string that does not
    contain them, and "dev" is replaced with an '@' so that it sorts lower than
    than any other pre-release tag.
    """
    parts = []
    for part in _parse_version_parts(s.lower()):
        if part.startswith('*'):
            if part<'*final':   # remove '-' before a prerelease tag
                while parts and parts[-1]=='*final-': parts.pop()
            # remove trailing zeros from each series of numeric parts
            while parts and parts[-1]=='00000000':
                parts.pop()
        parts.append(part)
    return tuple(parts)
        


src/m/i/minitage.recipe.egg-1.82/src/minitage/recipe/egg/egg.py   minitage.recipe.egg(Download)
                def version_compare(x, y):
                   if pkg_resources.parse_version(x)  > pkg_resources.parse_version(y):
                      return -1
                   elif pkg_resources.parse_version(x) == pkg_resources.parse_version(y):
                      return 0
                   else:
                      return 1

src/r/e/reporter-lib-HEAD/packages/setuptools/setuptools/command/egg_info.py   reporter-lib(Download)
from setuptools.command.sdist import sdist
from distutils.util import convert_path
from distutils.filelist import FileList
from pkg_resources import parse_requirements, safe_name, parse_version, \
    safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename
from sdist import walk_revctrl
 
        pd = self.distribution._patched_dist
        if pd is not None and pd.key==self.egg_name.lower():
            pd._version = self.egg_version
            pd._parsed_version = parse_version(self.egg_version)
            self.distribution._patched_dist = None
 
 

src/b/a/badger-lib-HEAD/packages/setuptools/setuptools/command/egg_info.py   badger-lib(Download)
from setuptools.command.sdist import sdist
from distutils.util import convert_path
from distutils.filelist import FileList
from pkg_resources import parse_requirements, safe_name, parse_version, \
    safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename
from sdist import walk_revctrl
 
        pd = self.distribution._patched_dist
        if pd is not None and pd.key==self.egg_name.lower():
            pd._version = self.egg_version
            pd._parsed_version = parse_version(self.egg_version)
            self.distribution._patched_dist = None
 
 

src/z/a/zamboni-lib-HEAD/lib/python/setuptools/command/egg_info.py   zamboni-lib(Download)
from setuptools.command.sdist import sdist
from distutils.util import convert_path
from distutils.filelist import FileList
from pkg_resources import parse_requirements, safe_name, parse_version, \
    safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename
from sdist import walk_revctrl
 
        pd = self.distribution._patched_dist
        if pd is not None and pd.key==self.egg_name.lower():
            pd._version = self.egg_version
            pd._parsed_version = parse_version(self.egg_version)
            self.distribution._patched_dist = None
 
 

src/d/i/distribute-0.6.14/setuptools/command/egg_info.py   distribute(Download)
from setuptools.command.sdist import sdist
from distutils.util import convert_path
from distutils.filelist import FileList
from pkg_resources import parse_requirements, safe_name, parse_version, \
    safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename
from sdist import walk_revctrl
 
        pd = self.distribution._patched_dist
        if pd is not None and pd.key==self.egg_name.lower():
            pd._version = self.egg_version
            pd._parsed_version = parse_version(self.egg_version)
            self.distribution._patched_dist = None
 
 

src/s/e/setuptools-0.6c11/setuptools/command/egg_info.py   setuptools(Download)
from setuptools.command.sdist import sdist
from distutils.util import convert_path
from distutils.filelist import FileList
from pkg_resources import parse_requirements, safe_name, parse_version, \
    safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename
from sdist import walk_revctrl
 
        pd = self.distribution._patched_dist
        if pd is not None and pd.key==self.egg_name.lower():
            pd._version = self.egg_version
            pd._parsed_version = parse_version(self.egg_version)
            self.distribution._patched_dist = None
 
 

src/t/o/ToscaWidgets-0.9.10/tw/mods/pylonshf.py   ToscaWidgets(Download)
import logging
 
from pkg_resources import parse_version
from decorator import decorator
 
from tw.api import retrieve_resources
from tw.mods.base import HostFramework
 
from formencode import Invalid
 
pylons_version = parse_version(pylons.__version__)
pylons_097_version = parse_version('0.9.7')
 
if pylons_version > pylons_097_version:

src/s/c/sconfigure-HEAD/TRUNK/sconfig/custom_scons_builders/xtools.py   sconfigure(Download)
 
from os.path import join, isdir, exists, isfile, abspath, splitext
from SCons.Script import Execute, Mkdir,Copy,Tool,Command
import SCons.Tool as SConsTool
from pkg_resources import parse_version
import re
import sys
def version_cmp( t1 ,t2 ):
    v1 = t1[0]
    v2 = t2[0]
    result = cmp( parse_version(v1), parse_version(v2) )
 
    return result
 
 
pat_restrict = re.compile( "(==|<|>|<=|>=|!=)?(.*)" )
 
def verson_filt( sign, versionstr, matchtostr ):
 
    version = parse_version(versionstr) 
    matchto = parse_version(matchtostr)

src/s/q/sqlkit-0.9.1/sqlkit/misc/utils.py   sqlkit(Download)
        warnings.warn(msg % (SA_VER, req))
 
    try:
        from pkg_resources import parse_version as pv
        if pv(sqlalchemy.__version__) >= pv(req):
            return  
        elif pv(sqlalchemy.__version__) < pv('0.5'):

src/h/a/haufe.eggserver-0.2.6/src/eggserver/eggsrv.py   haufe.eggserver(Download)
from zope.contenttype import guess_content_type
from util import *
import gocept.cache.method
from pkg_resources import parse_version
 
LOG = logging.getLogger('haufe-eggsrv')
 
def sort_packages(p1, p2):
    """ Compare two release package names based on their version string """
    return cmp(parse_version(p1), parse_version(p2))
 
def sort_dev_packages(p1, p2):
    """ Compare two dev package dicts based on their version string """
    return cmp(parse_version(p1['name']), parse_version(p2['name']))

  1 | 2 | 3 | 4 | 5 | 6  Next