本文整理汇总了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;
}
}
''')
示例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)
示例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
示例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
示例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
示例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
示例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')
示例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
示例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()
示例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
示例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)
示例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))
示例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
示例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
)
示例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)