本文整理汇总了Python中semantic_version.Version方法的典型用法代码示例。如果您正苦于以下问题:Python semantic_version.Version方法的具体用法?Python semantic_version.Version怎么用?Python semantic_version.Version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类semantic_version
的用法示例。
在下文中一共展示了semantic_version.Version方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _compare_build_json
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def _compare_build_json(self, contract_name: str) -> bool:
config = self._compiler_config
# confirm that this contract was previously compiled
try:
source = self._sources.get(contract_name)
build_json = self._build.get(contract_name)
except KeyError:
return True
# compare source hashes
if build_json["sha1"] != sha1(source.encode()).hexdigest():
return True
# compare compiler settings
if _compare_settings(config, build_json["compiler"]):
return True
if build_json["language"] == "Solidity":
# compare solc-specific compiler settings
solc_config = config["solc"].copy()
solc_config["remappings"] = None
if _compare_settings(solc_config, build_json["compiler"]):
return True
# compare solc pragma against compiled version
if Version(build_json["compiler"]["version"]) not in get_pragma_spec(source):
return True
return False
示例2: test_process_version_from_title
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def test_process_version_from_title():
"""Test converting title into version as per SemVer versioning"""
latest_version = Version("0.0.1")
title = '3.7.8 release'
match, version = process_version_from_title(title, latest_version)
assert version == "3.7.8"
assert match is True
title = 'new major release'
match, version = process_version_from_title(title, latest_version)
assert version == "1.0.0"
assert match is True
title = 'new minor release'
match, version = process_version_from_title(title, latest_version)
assert version == "0.1.0"
assert match is True
title = 'new patch release'
match, version = process_version_from_title(title, latest_version)
assert version == "0.0.2"
assert match is True
title = 'random release'
match, version = process_version_from_title(title, latest_version)
assert version == ""
assert match is False
示例3: resolve_custom_platform_version
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def resolve_custom_platform_version(
custom_platforms,
selected_platform_name
):
version_to_arn_mappings = generate_version_to_arn_mappings(
custom_platforms,
selected_platform_name
)
custom_platform_versions = []
for custom_platform_version in version_to_arn_mappings.keys():
custom_platform_versions.append(Version(custom_platform_version))
if len(custom_platform_versions) > 1:
chosen_custom_platform_arn = prompt_customer_for_custom_platform_version(
version_to_arn_mappings
)
else:
chosen_custom_platform_arn = custom_platforms[0]
return PlatformVersion(chosen_custom_platform_arn)
示例4: register
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def register(cfg, location, kernel):
first_run(cfg)
kernel_version = kernel
if kernel_version == 'latest':
templates = local.get_local_templates(pros_cfg=cfg.pros_cfg,
template_types=[TemplateTypes.kernel]) # type: List[Identifier]
if not templates or len(templates) == 0:
click.echo('No templates have been downloaded! Use `pros conduct download` to download the latest kernel or'
' specify a kernel manually.')
click.get_current_context().abort()
sys.exit()
kernel_version = sorted(templates, key=lambda t: semver.Version(t.version))[-1].version
proscli.utils.debug('Resolved version {} to {}'.format(kernel, kernel_version))
cfg = prosconfig.ProjectConfig(location, create=True, raise_on_error=True)
cfg.kernel = kernel_version
if not location:
click.echo('Location not specified, registering current directory.')
click.echo('Registering {} with kernel {}'.format(location or os.path.abspath('.'), kernel_version))
cfg.save()
# endregion
示例5: is_compatible
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [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
示例6: set_solc_version_pragma
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def set_solc_version_pragma(pragma_string, silent=False, check_new=False):
version = _select_pragma_version(
pragma_string, [Version(i[1:]) for i in get_installed_solc_versions()]
)
if not version:
raise SolcNotInstalled(
"No compatible solc version installed. "
+ "Use solcx.install_solc_version_pragma('{}') to install.".format(version)
)
version = _check_version(version)
global solc_version
solc_version = version
if not silent:
LOGGER.info("Using solc version {}".format(solc_version))
if check_new:
latest = install_solc_pragma(pragma_string, False)
if Version(latest) > Version(version[1:]):
LOGGER.info("Newer compatible solc version exists: {}".format(latest))
示例7: test_get_solc_version
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def test_get_solc_version():
version = get_solc_version()
assert isinstance(version, semantic_version.Version)
示例8: get_solc_version_string
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def get_solc_version_string(**kwargs):
kwargs['version'] = True
stdoutdata, stderrdata, command, proc = solc_wrapper(**kwargs)
_, _, version_string = stdoutdata.partition('\n')
if not version_string or not version_string.startswith('Version: '):
raise SolcError(
command=command,
return_code=proc.returncode,
stdin_data=None,
stdout_data=stdoutdata,
stderr_data=stderrdata,
message="Unable to extract version string from command output",
)
return version_string
示例9: get_solc_version
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def get_solc_version(**kwargs):
# semantic_version as of 2017-5-5 expects only one + to be used in string
return semantic_version.Version(
strip_zeroes_from_month_and_day(
get_solc_version_string(**kwargs)
[len('Version: '):]
.replace('++', 'pp')))
示例10: test_set_solc_version
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def test_set_solc_version():
compiler.set_solc_version("0.5.7")
assert solcx.get_solc_version().truncate() == compiler.solidity.get_version()
assert solcx.get_solc_version().truncate() == Version("0.5.7")
compiler.set_solc_version("0.4.25")
assert solcx.get_solc_version().truncate() == compiler.solidity.get_version()
assert solcx.get_solc_version().truncate() == Version("0.4.25")
示例11: test_generate_input_json_evm
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def test_generate_input_json_evm(solc5source, monkeypatch):
monkeypatch.setattr("solcx.get_solc_version", lambda: Version("0.5.5"))
fn = functools.partial(compiler.generate_input_json, {"path.sol": solc5source})
assert fn()["settings"]["evmVersion"] == "petersburg"
assert fn(evm_version="byzantium")["settings"]["evmVersion"] == "byzantium"
assert fn(evm_version="petersburg")["settings"]["evmVersion"] == "petersburg"
monkeypatch.setattr("solcx.get_solc_version", lambda: Version("0.5.4"))
assert fn()["settings"]["evmVersion"] == "byzantium"
assert fn(evm_version="byzantium")["settings"]["evmVersion"] == "byzantium"
assert fn(evm_version="petersburg")["settings"]["evmVersion"] == "petersburg"
示例12: get_version
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def get_version() -> Version:
return solcx.get_solc_version().truncate()
示例13: compile_from_input_json
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def compile_from_input_json(
input_json: Dict, silent: bool = True, allow_paths: Optional[str] = None
) -> Dict:
"""
Compiles contracts from a standard input json.
Args:
input_json: solc input json
silent: verbose reporting
allow_paths: compiler allowed filesystem import path
Returns: standard compiler output json
"""
optimizer = input_json["settings"]["optimizer"]
input_json["settings"].setdefault("evmVersion", None)
if input_json["settings"]["evmVersion"] in EVM_EQUIVALENTS:
input_json["settings"]["evmVersion"] = EVM_EQUIVALENTS[input_json["settings"]["evmVersion"]]
if not silent:
print(f"Compiling contracts...\n Solc version: {str(solcx.get_solc_version())}")
opt = f"Enabled Runs: {optimizer['runs']}" if optimizer["enabled"] else "Disabled"
print(f" Optimizer: {opt}")
if input_json["settings"]["evmVersion"]:
print(f" EVM Version: {input_json['settings']['evmVersion'].capitalize()}")
try:
return solcx.compile_standard(
input_json,
optimize=optimizer["enabled"],
optimize_runs=optimizer["runs"],
evm_version=input_json["settings"]["evmVersion"],
allow_paths=allow_paths,
)
except solcx.exceptions.SolcError as e:
raise CompilerError(e)
示例14: _get_solc_version_list
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def _get_solc_version_list() -> Tuple[List, List]:
global AVAILABLE_SOLC_VERSIONS
installed_versions = [Version(i[1:]) for i in solcx.get_installed_solc_versions()]
if AVAILABLE_SOLC_VERSIONS is None:
try:
AVAILABLE_SOLC_VERSIONS = [Version(i[1:]) for i in solcx.get_available_solc_versions()]
except ConnectionError:
if not installed_versions:
raise ConnectionError("Solc not installed and cannot connect to GitHub")
AVAILABLE_SOLC_VERSIONS = installed_versions
return AVAILABLE_SOLC_VERSIONS, installed_versions
示例15: installed_version
# 需要导入模块: import semantic_version [as 别名]
# 或者: from semantic_version import Version [as 别名]
def installed_version(self, name, version):
if name in self.packages:
pkg_version = self.get_package_version(name)
pkg_version = self._convert_old_version(pkg_version)
version = self._convert_old_version(version)
return (semantic_version.Version(pkg_version) ==
semantic_version.Version(version))