當前位置: 首頁>>代碼示例>>Python>>正文


Python semantic_version.Spec方法代碼示例

本文整理匯總了Python中semantic_version.Spec方法的典型用法代碼示例。如果您正苦於以下問題:Python semantic_version.Spec方法的具體用法?Python semantic_version.Spec怎麽用?Python semantic_version.Spec使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在semantic_version的用法示例。


在下文中一共展示了semantic_version.Spec方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: FOO_SOURCE

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def FOO_SOURCE(supported_solc_version, solc_version):
    if solc_version in Spec('<0.4.17'):
        return textwrap.dedent('''\
            pragma solidity ^0.4.0;

            contract Foo {
                function Foo() {}

                function return13() public returns (uint) {
                    return 13;
                }
            }
            ''')
    else:
        return textwrap.dedent('''\
            pragma solidity ^0.4.17;

            contract Foo {
                function Foo() public {}

                function return13() public pure returns (uint) {
                    return 13;
                }
            }
            ''') 
開發者ID:ethereum,項目名稱:py-solc,代碼行數:27,代碼來源:conftest.py

示例2: __init__

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def __init__(self, name, constraint, category='main'):
        self._name = name
        self._constraint = constraint
        self._optional = False
        self._accepts_prereleases = False
        self._category = category
        self._python = [Spec('*')]

        if isinstance(constraint, dict):
            if 'python' in constraint:
                python = constraint['python']

                if not isinstance(python, list):
                    python = [python]

                self._python = [Spec(p) for p in python]

            if 'optional' in constraint:
                self._optional = constraint['optional']

            if 'version' in constraint:
                self._constraint = constraint['version']

        self._normalized_constraint = self._normalize(constraint) 
開發者ID:sdispater,項目名稱:poet,代碼行數:26,代碼來源:dependency.py

示例3: is_compatible

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def is_compatible(self, platform_version, inclusive=False):
        """Checks if a release is compatible with a platform version

        :param platform_version: the platform version, not required to be
                                 semver compatible
        :param inclusive: if True the check will also return True if an app
                          requires 9.0.1 and the given platform version is 9.0
        :return: True if compatible, otherwise false
        """

        min_version = Version(pad_min_version(platform_version))
        spec = Spec(self.platform_version_spec)
        if inclusive:
            max_version = Version(pad_max_inc_version(platform_version))
            return (min_version in spec or max_version in spec)
        else:
            return min_version in spec 
開發者ID:nextcloud,項目名稱:appstore,代碼行數:19,代碼來源:models.py

示例4: v2_support_enabled

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def v2_support_enabled():
    docker_ver = docker_version(request.user_agent.string)

    # Check if our version is one of the blacklisted versions, if we can't
    # identify the version (None) we will fail open and assume that it is
    # newer and therefore should not be blacklisted.
    if docker_ver is not None and Spec(app.config["BLACKLIST_V2_SPEC"]).match(docker_ver):
        abort(404)

    response = make_response("true", 200)

    if get_authenticated_context() is None:
        response = make_response("true", 401)

    response.headers.extend(get_auth_headers())
    return response 
開發者ID:quay,項目名稱:quay,代碼行數:18,代碼來源:__init__.py

示例5: test_geth_installation_as_function_call

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def test_geth_installation_as_function_call(monkeypatch, tmpdir, platform, version):
    if get_platform() != platform:
        pytest.skip("Wrong platform for install script")

    base_install_path = str(tmpdir.mkdir("temporary-dir"))
    monkeypatch.setenv('GETH_BASE_INSTALL_PATH', base_install_path)

    # sanity check that it's not already installed.
    executable_path = get_executable_path(version)
    assert not os.path.exists(executable_path)

    install_geth(identifier=version, platform=platform)

    assert os.path.exists(executable_path)
    monkeypatch.setenv('GETH_BINARY', executable_path)

    actual_version = get_geth_version()
    expected_version = semantic_version.Spec(version.lstrip('v'))

    assert actual_version in expected_version 
開發者ID:ethereum,項目名稱:py-geth,代碼行數:22,代碼來源:test_geth_installation.py

示例6: supported_solc_version

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def supported_solc_version(solc_version):
    if solc_version not in Spec('>=0.4.1,<=0.4.25,!=0.4.10,!=0.4.3,!=0.4.4,!=0.4.5'):
        raise AssertionError("Unsupported compiler version: {0}".format(solc_version))

    return solc_version 
開發者ID:ethereum,項目名稱:py-solc,代碼行數:7,代碼來源:conftest.py

示例7: is_new_key_format

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def is_new_key_format():
    return get_solc_version() in Spec('>=0.4.9') 
開發者ID:ethereum,項目名稱:py-solc,代碼行數:4,代碼來源:conftest.py

示例8: test_solc_installation_as_function_call

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def test_solc_installation_as_function_call(monkeypatch, tmpdir, platform, version):
    if get_platform() != platform:
        pytest.skip("Wront platform for install script")

    base_install_path = str(tmpdir.mkdir("temporary-dir"))
    monkeypatch.setenv('SOLC_BASE_INSTALL_PATH', base_install_path)

    # sanity check that it's not already installed.
    executable_path = get_executable_path(version)
    assert not os.path.exists(executable_path)

    install_solc(identifier=version, platform=platform)

    assert os.path.exists(executable_path)
    monkeypatch.setenv('SOLC_BINARY', executable_path)

    extract_path = get_extract_path(version)
    if os.path.exists(extract_path):
        contains_so_file = any(
            os.path.basename(path).partition(os.path.extsep)[2] == 'so'
            for path
            in os.listdir(extract_path)
        )
        if contains_so_file:
            monkeypatch.setenv('LD_LIBRARY_PATH', extract_path)

    actual_version = get_solc_version()
    expected_version = semantic_version.Spec(version.lstrip('v'))

    assert actual_version in expected_version 
開發者ID:ethereum,項目名稱:py-solc,代碼行數:32,代碼來源:test_solc_installation.py

示例9: test_solc_supports_standard_json_interface

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def test_solc_supports_standard_json_interface():
    version = get_solc_version()

    if version in semantic_version.Spec("<0.4.11"):
        assert not solc_supports_standard_json_interface()
    else:
        assert solc_supports_standard_json_interface() 
開發者ID:ethereum,項目名稱:py-solc,代碼行數:9,代碼來源:test_solc_supports_standard_json.py

示例10: check_package_version

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def check_package_version(version, spec_version):
    try:
        spec = semantic_version.Spec(spec_version)
        return semantic_version.Version(version) in spec
    except ValueError:
        pass 
開發者ID:FPGAwars,項目名稱:apio,代碼行數:8,代碼來源:util.py

示例11: check_pip_packages

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def check_pip_packages(self, board_data):
        prog_info = board_data.get('programmer')
        content = self.resources.programmers.get(prog_info.get('type'))
        all_pip_packages = self.resources.distribution.get('pip_packages')

        pip_packages = content.get('pip_packages') or []
        for pip_pkg in pip_packages:
            try:
                # Check pip_package version
                spec = semantic_version.Spec(all_pip_packages.get(pip_pkg, ''))
                pkg_version = pkg_resources.get_distribution(pip_pkg).version
                version = semantic_version.Version(pkg_version)
                if not spec.match(version):
                    click.secho(
                        'Error: \'{}\' '.format(pip_pkg) +
                        'version ({}) '.format(version) +
                        'does not match {}'.format(spec),
                        fg='red')
                    click.secho('Please run:\n'
                                '   pip install -U apio[{}]'.format(pip_pkg),
                                fg='yellow')
                    raise Exception
            except pkg_resources.DistributionNotFound:
                click.secho(
                    'Error: \'{}\' is not installed'.format(pip_pkg),
                    fg='red')
                click.secho('Please run:\n'
                            '   pip install -U apio[{}]'.format(pip_pkg),
                            fg='yellow')
                raise Exception
            try:
                # Check pip_package itself
                __import__(pip_pkg)
            except Exception as e:
                # Exit if a package is not working
                python_version = util.get_python_version()
                message = '\'{}\' not compatible with '.format(pip_pkg)
                message += 'Python {}'.format(python_version)
                message += '\n       {}'.format(e)
                raise Exception(message) 
開發者ID:FPGAwars,項目名稱:apio,代碼行數:42,代碼來源:scons.py

示例12: select_version

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def select_version(versions_str, query, stable=False):
    if isinstance(query, str):
        query = query.split(",")
    query = [x.replace(" ", "") for x in query]
    stable = True
    if "-" in str(query):
        stable = False
    spec = Spec(*query)
    return spec.select(versions(versions_str, stable)) 
開發者ID:app-registry,項目名稱:appr,代碼行數:11,代碼來源:semver.py

示例13: test_fix_version

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def test_fix_version(self):
        import semantic_version
        ver = u'17.03.01-ce'
        fixed_ver = _fix_version(ver)
        assert fixed_ver == u'17.3.1'
        VERSION_SPEC = semantic_version.Spec('>=1.10.0')
        assert VERSION_SPEC.match(semantic_version.Version(fixed_ver)) is True 
開發者ID:cloudviz,項目名稱:agentless-system-crawler,代碼行數:9,代碼來源:test_functional_dockerutils.py

示例14: get_rust_version

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def get_rust_version(self):
        if self.rust_version is None:
            return None
        try:
            return semantic_version.Spec(self.rust_version)
        except ValueError:
            raise DistutilsSetupError(
                "Can not parse rust compiler version: %s", self.rust_version
            ) 
開發者ID:PyO3,項目名稱:setuptools-rust,代碼行數:11,代碼來源:extension.py

示例15: is_tensorflow_version_newer

# 需要導入模塊: import semantic_version [as 別名]
# 或者: from semantic_version import Spec [as 別名]
def is_tensorflow_version_newer(version: str, tf_module):
  """Determines the Tensorflow module is newer than a specified version.

  This function should be used when we wish to take dependency on some behavior
  present in newer but not older versions of TensorFlow. When adding a usage
  of this, please perform the following steps:

  1. File a bug to clean up the usage of this check--once the latest released
     TensorFlow version contains this behavior, we want to remove it.

  2. Log in the true and false cases, and ensure that the default behavior is
     the one you expect.

  Args:
    version: a `str` in the semantic versioning format 'major.minor.patch'.
    tf_module: the TensorFlow module to assert the version against.

  Returns:
    `True` iff `tf_module` is versions at or newer than `version` string, or
  the is determined to be a nightly pre-release version of TensorFlow.
  """
  tf_version = semantic_version.Version(tf_module.version.VERSION)
  if tf_version.prerelease:
    # tf-nightly uses versions like MAJOR.MINOR.PATCH-devYYYYMMDD
    if tf_version.prerelease[0].startswith('dev2020'):
      return True
  version_spec = semantic_version.Spec('>={v}'.format(v=version))
  return version_spec.match(tf_version) 
開發者ID:tensorflow,項目名稱:federated,代碼行數:30,代碼來源:version_check.py


注:本文中的semantic_version.Spec方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。