當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。