当前位置: 首页>>代码示例>>Python>>正文


Python version.StrictVersion方法代码示例

本文整理汇总了Python中distutils.version.StrictVersion方法的典型用法代码示例。如果您正苦于以下问题:Python version.StrictVersion方法的具体用法?Python version.StrictVersion怎么用?Python version.StrictVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在distutils.version的用法示例。


在下文中一共展示了version.StrictVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_default_values

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def test_default_values(self):

        field_name = 'custom_integer_field'
        self.assertEqual(5, self.get_default_value(field_name, True))
        self.assertEqual(5, self.get_default_value(field_name))

        if StrictVersion(VERSION) >= StrictVersion('3.0.0'):
            return

        field_name = 'boolean_field'
        self.assertEqual(False, self.get_default_value(field_name, True))
        self.assertEqual(False, self.get_default_value(field_name))

        field_name = 'choices_field'
        self.assertEqual('a', self.get_default_value(field_name, True))
        self.assertEqual('a', self.get_default_value(field_name))

        field_name = 'decimal_field'
        self.assertEqual(100.0, self.get_default_value(field_name, True))
        self.assertEqual(100.0, self.get_default_value(field_name))

        field_name = 'integer_field'
        self.assertEqual(0, self.get_default_value(field_name, True))
        self.assertEqual(0, self.get_default_value(field_name)) 
开发者ID:Arello-Mobile,项目名称:py2swagger,代码行数:26,代码来源:test_serializer_introspector.py

示例2: test_default_serializer

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def test_default_serializer(self):
        if StrictVersion(VERSION) >= StrictVersion('3.0.0'):
            return

        from rest_framework.viewsets import ModelViewSet
        from django.http import HttpRequest
        from testapp.models import TestModel

        class TestViewSet(ModelViewSet):
            model = TestModel

        view = TestViewSet()
        view.request = HttpRequest()

        si = SerializerIntrospector(view.get_serializer_class())

        self.assertEqual(si.name, 'TestModelSerializer') 
开发者ID:Arello-Mobile,项目名称:py2swagger,代码行数:19,代码来源:test_serializer_introspector.py

示例3: test_create_fb

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def test_create_fb(self):
        self._test_create_fb()
        self._test_create_fb(n_mels=128, sample_rate=44100)
        self._test_create_fb(n_mels=128, fmin=2000.0, fmax=5000.0)
        self._test_create_fb(n_mels=56, fmin=100.0, fmax=9000.0)
        self._test_create_fb(n_mels=56, fmin=800.0, fmax=900.0)
        self._test_create_fb(n_mels=56, fmin=1900.0, fmax=900.0)
        self._test_create_fb(n_mels=10, fmin=1900.0, fmax=900.0)
        if StrictVersion(librosa.__version__) < StrictVersion("0.7.2"):
            return
        self._test_create_fb(n_mels=128, sample_rate=44100, norm="slaney")
        self._test_create_fb(n_mels=128, fmin=2000.0, fmax=5000.0, norm="slaney")
        self._test_create_fb(n_mels=56, fmin=100.0, fmax=9000.0, norm="slaney")
        self._test_create_fb(n_mels=56, fmin=800.0, fmax=900.0, norm="slaney")
        self._test_create_fb(n_mels=56, fmin=1900.0, fmax=900.0, norm="slaney")
        self._test_create_fb(n_mels=10, fmin=1900.0, fmax=900.0, norm="slaney") 
开发者ID:pytorch,项目名称:audio,代码行数:18,代码来源:test_librosa_compatibility.py

示例4: make_env

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def make_env(args, seed, test):
    if args.env.startswith('Roboschool'):
        # Check gym version because roboschool does not work with gym>=0.15.6
        from distutils.version import StrictVersion
        gym_version = StrictVersion(gym.__version__)
        if gym_version >= StrictVersion('0.15.6'):
            raise RuntimeError('roboschool does not work with gym>=0.15.6')
        import roboschool  # NOQA
    env = gym.make(args.env)
    # Unwrap TimiLimit wrapper
    assert isinstance(env, gym.wrappers.TimeLimit)
    env = env.env
    # Use different random seeds for train and test envs
    env_seed = 2 ** 32 - 1 - seed if test else seed
    env.seed(int(env_seed))
    # Cast observations to float32 because our model uses float32
    env = chainerrl.wrappers.CastObservationToFloat32(env)
    # Normalize action space to [-1, 1]^n
    env = chainerrl.wrappers.NormalizeActionSpace(env)
    if args.monitor:
        env = chainerrl.wrappers.Monitor(
            env, args.outdir, force=True, video_callable=lambda _: True)
    if args.render:
        env = chainerrl.wrappers.Render(env, mode='human')
    return env 
开发者ID:chainer,项目名称:chainerrl,代码行数:27,代码来源:train_soft_actor_critic_atlas.py

示例5: compare_version

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def compare_version(v1, v2):
    """TODO: Compare hyperledger versions

    >>> v1 = '1.1'
    >>> v2 = '1.10'
    >>> compare_version(v1, v2)
    1
    >>> compare_version(v2, v1)
    -1
    >>> compare_version(v2, v2)
    0
    """
    s1 = StrictVersion(v1)
    s2 = StrictVersion(v2)
    if s1 == s2:
        return 0
    elif s1 > s2:
        return -1
    else:
        return 1 
开发者ID:yeasy,项目名称:hyperledger-py,代码行数:22,代码来源:utils.py

示例6: check_update

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def check_update():
    """Check for script version.

    Check latest version on Github page.

    Returns:
        bool, True for new version released.
    """
    echoinfo('Checking update...')
    req = requests.get(__update_url__)
    if StrictVersion(req.text) > StrictVersion(__version__):
        echoinfo('Found new version: '+req.text)
        echowarning(
            'New version found! We strongly recommand you to update to the latest version!')
        echowarning('Use "pip3 install sjtu-automata --upgrade" to upgrade!')

        return True
    else:
        echoinfo('You are up-to-date!')
    return False 
开发者ID:MXWXZ,项目名称:sjtu-automata,代码行数:22,代码来源:__init__.py

示例7: get_package_version

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def get_package_version():
    """Extracts the highest version number of the pygrametl python files"""

    # The minimum version number is used for the initial value
    version_number = StrictVersion("0.0")

    python_files = glob.glob(pygrametl_path + '*.py')
    for python_file in python_files:
        # The path of each module is computed and its version extracted
        module_name = os.path.basename(python_file)[:-3]
        version = __import__(module_name).__version__

        # A alpha / beta version without a number is the first alpha / beta
        if version.endswith(('a', 'b')):
            strict_version = StrictVersion(version + '1')
        else:
            strict_version = StrictVersion(version)

        # If a higher version number is found then that it is used
        if strict_version > version_number:
            version_number = strict_version

    return str(version_number) 
开发者ID:chrthomsen,项目名称:pygrametl,代码行数:25,代码来源:version.py

示例8: find_class

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def find_class(self, module, name):
        """
        Helps Unpickler to find certain Numpy modules.
        """

        try:
            numpy_version = StrictVersion(numpy.__version__)

            if numpy_version >= StrictVersion('1.5.0'):
                if module == 'numpy.core.defmatrix':
                    module = 'numpy.matrixlib.defmatrix'

        except ValueError:
            pass

        return Unpickler.find_class(self, module, name) 
开发者ID:lucastheis,项目名称:c2s,代码行数:18,代码来源:experiment.py

示例9: get_metadata_version

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def get_metadata_version(self):
    mv = getattr(self, 'metadata_version', None)

    if mv is None:
        if self.long_description_content_type or self.provides_extras:
            mv = StrictVersion('2.1')
        elif (self.maintainer is not None or
              self.maintainer_email is not None or
              getattr(self, 'python_requires', None) is not None):
            mv = StrictVersion('1.2')
        elif (self.provides or self.requires or self.obsoletes or
                self.classifiers or self.download_url):
            mv = StrictVersion('1.1')
        else:
            mv = StrictVersion('1.0')

        self.metadata_version = mv

    return mv 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:21,代码来源:dist.py

示例10: get_metadata_version

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def get_metadata_version(self):
    mv = getattr(self, 'metadata_version', None)

    if mv is None:
        if self.long_description_content_type or self.provides_extras:
            mv = StrictVersion('2.1')
        elif (self.maintainer is not None or
              self.maintainer_email is not None or
              getattr(self, 'python_requires', None) is not None or
              self.project_urls):
            mv = StrictVersion('1.2')
        elif (self.provides or self.requires or self.obsoletes or
                self.classifiers or self.download_url):
            mv = StrictVersion('1.1')
        else:
            mv = StrictVersion('1.0')

        self.metadata_version = mv

    return mv 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:dist.py

示例11: __init__

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def __init__(self, redis_pool, *, cookie_name="AIOHTTP_SESSION",
                 domain=None, max_age=None, path='/',
                 secure=None, httponly=True,
                 key_factory=lambda: uuid.uuid4().hex,
                 encoder=json.dumps, decoder=json.loads):
        super().__init__(cookie_name=cookie_name, domain=domain,
                         max_age=max_age, path=path, secure=secure,
                         httponly=httponly,
                         encoder=encoder, decoder=decoder)
        if aioredis is None:
            raise RuntimeError("Please install aioredis")
        if StrictVersion(aioredis.__version__).version < (1, 0):
            raise RuntimeError("aioredis<1.0 is not supported")
        self._key_factory = key_factory
        if isinstance(redis_pool, aioredis.pool.ConnectionsPool):
            warnings.warn(
                "using a pool created with aioredis.create_pool is deprecated"
                "please use a pool created with aioredis.create_redis_pool",
                DeprecationWarning
            )
            redis_pool = aioredis.commands.Redis(redis_pool)
        elif not isinstance(redis_pool, aioredis.commands.Redis):
            raise TypeError("Expexted aioredis.commands.Redis got {}".format(
                    type(redis_pool)))
        self._redis = redis_pool 
开发者ID:aio-libs,项目名称:aiohttp-session,代码行数:27,代码来源:redis_storage.py

示例12: check_pip_version

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def check_pip_version(min_version='6.0.0'):
    """
    Ensure that a minimum supported version of pip is installed.
    """
    check_pip_is_installed()

    import pip

    if StrictVersion(pip.__version__) < StrictVersion(min_version):
        print("Upgrade pip, your version '{0}' "
              "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__,
                                                                            min_version,
                                                                            GET_PIP))
        sys.exit(1)

    return True 
开发者ID:StackStorm,项目名称:st2-auth-backend-ldap,代码行数:18,代码来源:dist_utils.py

示例13: compare_version

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def compare_version(v1, v2):
    """Compare docker versions

    >>> v1 = '1.9'
    >>> v2 = '1.10'
    >>> compare_version(v1, v2)
    1
    >>> compare_version(v2, v1)
    -1
    >>> compare_version(v2, v2)
    0
    """
    s1 = StrictVersion(v1)
    s2 = StrictVersion(v2)
    if s1 == s2:
        return 0
    elif s1 > s2:
        return -1
    else:
        return 1 
开发者ID:QData,项目名称:deepWordBug,代码行数:22,代码来源:utils.py

示例14: init_callback

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def init_callback(self):
        self.client = docker.Client(
            base_url=self.docker_url,
            version=DockerPlugin.MIN_DOCKER_API_VERSION)
        self.client.timeout = self.timeout

        # Check API version for stats endpoint support.
        try:
            version = self.client.version()['ApiVersion']
            if StrictVersion(version) < \
                    StrictVersion(DockerPlugin.MIN_DOCKER_API_VERSION):
                raise Exception
        except:
            collectd.warning(('Docker daemon at {url} does not '
                              'support container statistics!')
                             .format(url=self.docker_url))
            return False

        collectd.register_read(self.read_callback)
        collectd.info(('Collecting stats about Docker containers from {url} '
                       '(API version {version}; timeout: {timeout}s).')
                      .format(url=self.docker_url,
                              version=version,
                              timeout=self.timeout))
        return True 
开发者ID:lebauce,项目名称:docker-collectd-plugin,代码行数:27,代码来源:dockerplugin.py

示例15: _check_compatibility

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import StrictVersion [as 别名]
def _check_compatibility(self):
        from distutils.version import StrictVersion
        cmd = [self.bins['iptables'], '--version']
        rc, stdout, stderr = Iptables.module.run_command(cmd, check_rc=False)
        if rc == 0:
            result = re.search(r'^ip6tables\s+v(\d+\.\d+)\.\d+$', stdout)
            if result:
                version = result.group(1)
                # CentOS 5 ip6tables (v1.3.x) doesn't support comments,
                # which means it cannot be used with this module.
                if StrictVersion(version) < StrictVersion('1.4'):
                    Iptables.module.fail_json(msg="This module isn't compatible with ip6tables versions older than 1.4.x")
        else:
            Iptables.module.fail_json(msg="Could not fetch iptables version! Is iptables installed?")

    # Read rules from the json state file and return a dict. 
开发者ID:cogini,项目名称:elixir-deploy-template,代码行数:18,代码来源:iptables_raw.py


注:本文中的distutils.version.StrictVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。