本文整理汇总了Python中spack.spec.Spec.format方法的典型用法代码示例。如果您正苦于以下问题:Python Spec.format方法的具体用法?Python Spec.format怎么用?Python Spec.format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spack.spec.Spec
的用法示例。
在下文中一共展示了Spec.format方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dynamic_dot_graph_mpileaks
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import format [as 别名]
def test_dynamic_dot_graph_mpileaks(mock_packages):
"""Test dynamically graphing the mpileaks package."""
s = Spec('mpileaks').normalized()
stream = StringIO()
graph_dot([s], static=False, out=stream)
dot = stream.getvalue()
mpileaks_hash, mpileaks_lbl = s.dag_hash(), s.format('$_$/')
mpi_hash, mpi_lbl = s['mpi'].dag_hash(), s['mpi'].format('$_$/')
callpath_hash, callpath_lbl = (
s['callpath'].dag_hash(), s['callpath'].format('$_$/'))
dyninst_hash, dyninst_lbl = (
s['dyninst'].dag_hash(), s['dyninst'].format('$_$/'))
libdwarf_hash, libdwarf_lbl = (
s['libdwarf'].dag_hash(), s['libdwarf'].format('$_$/'))
libelf_hash, libelf_lbl = (
s['libelf'].dag_hash(), s['libelf'].format('$_$/'))
assert ' "%s" [label="%s"]\n' % (mpileaks_hash, mpileaks_lbl) in dot
assert ' "%s" [label="%s"]\n' % (callpath_hash, callpath_lbl) in dot
assert ' "%s" [label="%s"]\n' % (mpi_hash, mpi_lbl) in dot
assert ' "%s" [label="%s"]\n' % (dyninst_hash, dyninst_lbl) in dot
assert ' "%s" [label="%s"]\n' % (libdwarf_hash, libdwarf_lbl) in dot
assert ' "%s" [label="%s"]\n' % (libelf_hash, libelf_lbl) in dot
assert ' "%s" -> "%s"\n' % (dyninst_hash, libdwarf_hash) in dot
assert ' "%s" -> "%s"\n' % (callpath_hash, dyninst_hash) in dot
assert ' "%s" -> "%s"\n' % (mpileaks_hash, mpi_hash) in dot
assert ' "%s" -> "%s"\n' % (libdwarf_hash, libelf_hash) in dot
assert ' "%s" -> "%s"\n' % (callpath_hash, mpi_hash) in dot
assert ' "%s" -> "%s"\n' % (mpileaks_hash, callpath_hash) in dot
assert ' "%s" -> "%s"\n' % (dyninst_hash, libelf_hash) in dot
示例2: test_yaml_directory_layout_parameters
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import format [as 别名]
def test_yaml_directory_layout_parameters(
tmpdir, config
):
"""This tests the various parameters that can be used to configure
the install location """
spec = Spec('python')
spec.concretize()
# Ensure default layout matches expected spec format
layout_default = YamlDirectoryLayout(str(tmpdir))
path_default = layout_default.relative_path_for_spec(spec)
assert(path_default == spec.format(
"${ARCHITECTURE}/"
"${COMPILERNAME}-${COMPILERVER}/"
"${PACKAGE}-${VERSION}-${HASH}"))
# Test hash_length parameter works correctly
layout_10 = YamlDirectoryLayout(str(tmpdir), hash_len=10)
path_10 = layout_10.relative_path_for_spec(spec)
layout_7 = YamlDirectoryLayout(str(tmpdir), hash_len=7)
path_7 = layout_7.relative_path_for_spec(spec)
assert(len(path_default) - len(path_10) == 22)
assert(len(path_default) - len(path_7) == 25)
# Test path_scheme
arch, compiler, package7 = path_7.split('/')
scheme_package7 = "${PACKAGE}-${VERSION}-${HASH:7}"
layout_package7 = YamlDirectoryLayout(str(tmpdir),
path_scheme=scheme_package7)
path_package7 = layout_package7.relative_path_for_spec(spec)
assert(package7 == path_package7)
# Test separation of architecture
arch_scheme_package = "${PLATFORM}/${TARGET}/${OS}/${PACKAGE}/${VERSION}/${HASH:7}" # NOQA: ignore=E501
layout_arch_package = YamlDirectoryLayout(str(tmpdir),
path_scheme=arch_scheme_package)
arch_path_package = layout_arch_package.relative_path_for_spec(spec)
assert(arch_path_package == spec.format(arch_scheme_package))
# Ensure conflicting parameters caught
with pytest.raises(InvalidDirectoryLayoutParametersError):
YamlDirectoryLayout(str(tmpdir),
hash_len=20,
path_scheme=scheme_package7)
示例3: test_spec_formatting
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import format [as 别名]
def test_spec_formatting(self):
spec = Spec("libelf cflags=-O2")
spec.concretize()
# Since the default is the full spec see if the string rep of
# spec is the same as the output of spec.format()
# ignoring whitespace (though should we?)
assert str(spec) == spec.format().strip()
# Testing named strings ie ${STRING} and whether we get
# the correct component
package_segments = [("${PACKAGE}", "name"),
("${VERSION}", "versions"),
("${COMPILER}", "compiler"),
("${COMPILERFLAGS}", "compiler_flags"),
("${OPTIONS}", "variants"),
("${ARCHITECTURE}", "architecture")]
compiler_segments = [("${COMPILERNAME}", "name"),
("${COMPILERVER}", "versions")]
architecture_segments = [("${PLATFORM}", "platform"),
("${OS}", "platform_os"),
("${TARGET}", "target")]
for named_str, prop in package_segments:
expected = getattr(spec, prop, "")
actual = spec.format(named_str)
assert str(expected) == actual
compiler = spec.compiler
for named_str, prop in compiler_segments:
expected = getattr(compiler, prop, "")
actual = spec.format(named_str)
assert str(expected) == actual
arch = spec.architecture
for named_str, prop in architecture_segments:
expected = getattr(arch, prop, "")
actual = spec.format(named_str)
assert str(expected) == actual