当前位置: 首页>>代码示例>>Python>>正文


Python Spec.normalize方法代码示例

本文整理汇总了Python中spack.spec.Spec.normalize方法的典型用法代码示例。如果您正苦于以下问题:Python Spec.normalize方法的具体用法?Python Spec.normalize怎么用?Python Spec.normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在spack.spec.Spec的用法示例。


在下文中一共展示了Spec.normalize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_using_ordered_dict

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
def test_using_ordered_dict(builtin_mock):
    """ Checks that dicts are ordered

    Necessary to make sure that dag_hash is stable across python
    versions and processes.
    """
    def descend_and_check(iterable, level=0):
        if isinstance(iterable, Mapping):
            assert isinstance(iterable, syaml_dict)
            return descend_and_check(iterable.values(), level=level + 1)
        max_level = level
        for value in iterable:
            if isinstance(value, Iterable) and not isinstance(value, str):
                nlevel = descend_and_check(value, level=level + 1)
                if nlevel > max_level:
                    max_level = nlevel
        return max_level

    specs = ['mpileaks ^zmpi', 'dttop', 'dtuse']
    for spec in specs:
        dag = Spec(spec)
        dag.normalize()
        from pprint import pprint
        pprint(dag.to_node_dict())
        break

        level = descend_and_check(dag.to_node_dict())

        # level just makes sure we are doing something here
        assert level >= 5
开发者ID:justintoo,项目名称:spack,代码行数:32,代码来源:spec_yaml.py

示例2: test_spec_contains_deps

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
 def test_spec_contains_deps(self):
     s = Spec('callpath')
     s.normalize()
     assert 'dyninst' in s
     assert 'libdwarf' in s
     assert 'libelf' in s
     assert 'mpi' in s
开发者ID:LLNL,项目名称:spack,代码行数:9,代码来源:spec_semantics.py

示例3: test_normalize_diamond_deptypes

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
    def test_normalize_diamond_deptypes(self):
        """Ensure that dependency types are preserved even if the same thing is
           depended on in two different ways."""
        s = Spec('dt-diamond')
        s.normalize()

        self.check_diamond_deptypes(s)
        self.check_diamond_normalized_dag(s)
开发者ID:justintoo,项目名称:spack,代码行数:10,代码来源:spec_dag.py

示例4: test_compiler_inheritance

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
 def test_compiler_inheritance(self):
     spec = Spec('mpileaks')
     spec.normalize()
     spec['dyninst'].compiler = CompilerSpec('clang')
     spec.concretize()
     # TODO: not exactly the syntax I would like.
     assert spec['libdwarf'].compiler.satisfies('clang')
     assert spec['libelf'].compiler.satisfies('clang')
开发者ID:LLNL,项目名称:spack,代码行数:10,代码来源:concretize.py

示例5: test_deptype_traversal_run

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
    def test_deptype_traversal_run(self):
        dag = Spec('dttop')
        dag.normalize()

        names = ['dttop', 'dtrun1', 'dtrun3']

        traversal = dag.traverse(deptype='run')
        assert [x.name for x in traversal] == names
开发者ID:justintoo,项目名称:spack,代码行数:10,代码来源:spec_dag.py

示例6: test_my_dep_depends_on_provider_of_my_virtual_dep

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
    def test_my_dep_depends_on_provider_of_my_virtual_dep(self):
        spec = Spec('indirect_mpich')
        spec.normalize()

        print
        print spec.tree(color=True)

        spec.concretize()
开发者ID:jprotze,项目名称:spack,代码行数:10,代码来源:concretize.py

示例7: test_deptype_traversal_with_builddeps

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
    def test_deptype_traversal_with_builddeps(self):
        dag = Spec('dttop')
        dag.normalize()

        names = ['dttop', 'dtbuild1', 'dtbuild2', 'dtlink2',
                 'dtlink1', 'dtlink3', 'dtlink4']

        traversal = dag.traverse(deptype=('build', 'link'))
        assert [x.name for x in traversal] == names
开发者ID:justintoo,项目名称:spack,代码行数:11,代码来源:spec_dag.py

示例8: test_normalize_twice

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
    def test_normalize_twice(self):
        """Make sure normalize can be run twice on the same spec,
           and that it is idempotent."""
        spec = Spec('mpileaks')
        spec.normalize()
        n1 = spec.copy()

        spec.normalize()
        self.assertEqual(n1, spec)
开发者ID:jgalarowicz,项目名称:spack,代码行数:11,代码来源:spec_dag.py

示例9: test_conflicting_package_constraints

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
    def test_conflicting_package_constraints(self, set_dependency):
        set_dependency('mpileaks', '[email protected]')
        set_dependency('callpath', '[email protected]')

        spec = Spec('mpileaks ^mpich ^callpath ^dyninst ^libelf ^libdwarf')

        # TODO: try to do something to show that the issue was with
        # TODO: the user's input or with package inconsistencies.
        with pytest.raises(spack.spec.UnsatisfiableVersionSpecError):
            spec.normalize()
开发者ID:justintoo,项目名称:spack,代码行数:12,代码来源:spec_dag.py

示例10: test_compiler_inheritance

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
    def test_compiler_inheritance(self):
        spec = Spec("mpileaks")
        spec.normalize()

        spec["dyninst"].compiler = CompilerSpec("clang")
        spec.concretize()

        # TODO: not exactly the syntax I would like.
        self.assertTrue(spec["libdwarf"].compiler.satisfies("clang"))
        self.assertTrue(spec["libelf"].compiler.satisfies("clang"))
开发者ID:dshrader,项目名称:spack,代码行数:12,代码来源:concretize.py

示例11: test_conflicting_spec_constraints

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
    def test_conflicting_spec_constraints(self):
        mpileaks = Spec('mpileaks ^mpich ^callpath ^dyninst ^libelf ^libdwarf')

        # Normalize then add conflicting constraints to the DAG (this is an
        # extremely unlikely scenario, but we test for it anyway)
        mpileaks.normalize()
        mpileaks.dependencies['mpich'] = Spec('[email protected]')
        mpileaks.dependencies['callpath'].dependencies['mpich'] = Spec('[email protected]')

        self.assertRaises(spack.spec.InconsistentSpecError, mpileaks.flatten)
开发者ID:jgalarowicz,项目名称:spack,代码行数:12,代码来源:spec_dag.py

示例12: test_deptype_traversal_full

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
    def test_deptype_traversal_full(self):
        dag = Spec('dttop')
        dag.normalize()

        names = ['dttop', 'dtbuild1', 'dtbuild2', 'dtlink2', 'dtrun2',
                 'dtlink1', 'dtlink3', 'dtlink4', 'dtrun1', 'dtlink5',
                 'dtrun3', 'dtbuild3']

        traversal = dag.traverse(deptype=spack.alldeps)
        assert [x.name for x in traversal] == names
开发者ID:justintoo,项目名称:spack,代码行数:12,代码来源:spec_dag.py

示例13: test_read_and_write_spec

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
    def test_read_and_write_spec(self):
        """This goes through each package in spack and creates a directory for
           it.  It then ensures that the spec for the directory's
           installed package can be read back in consistently, and
           finally that the directory can be removed by the directory
           layout.
        """
        for pkg in spack.db.all_packages():
            spec = pkg.spec

            # If a spec fails to concretize, just skip it.  If it is a
            # real error, it will be caught by concretization tests.
            try:
                spec.concretize()
            except:
                continue

            self.layout.make_path_for_spec(spec)

            install_dir = self.layout.path_for_spec(spec)
            spec_path = self.layout.spec_file_path(spec)

            # Ensure directory has been created in right place.
            self.assertTrue(os.path.isdir(install_dir))
            self.assertTrue(install_dir.startswith(self.tmpdir))

            # Ensure spec file exists when directory is created
            self.assertTrue(os.path.isfile(spec_path))
            self.assertTrue(spec_path.startswith(install_dir))

            # Make sure spec file can be read back in to get the original spec
            spec_from_file = self.layout.read_spec(spec_path)
            self.assertEqual(spec, spec_from_file)
            self.assertTrue(spec.eq_dag, spec_from_file)
            self.assertTrue(spec_from_file.concrete)

            # Ensure that specs that come out "normal" are really normal.
            with closing(open(spec_path)) as spec_file:
                read_separately = Spec(spec_file.read())

                read_separately.normalize()
                self.assertEqual(read_separately, spec_from_file)

                read_separately.concretize()
                self.assertEqual(read_separately, spec_from_file)

            # Make sure the dep hash of the read-in spec is the same
            self.assertEqual(spec.dep_hash(), spec_from_file.dep_hash())

            # Ensure directories are properly removed
            self.layout.remove_path_for_spec(spec)
            self.assertFalse(os.path.isdir(install_dir))
            self.assertFalse(os.path.exists(install_dir))
开发者ID:AaronTHolt,项目名称:spack,代码行数:55,代码来源:directory_layout.py

示例14: test_preorder_path_traversal

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
    def test_preorder_path_traversal(self):
        dag = Spec('mpileaks ^zmpi')
        dag.normalize()

        names = ['mpileaks', 'callpath', 'dyninst', 'libdwarf', 'libelf',
                 'libelf', 'zmpi', 'fake', 'zmpi', 'fake']
        pairs = zip([0,1,2,3,4,3,2,3,1,2], names)

        traversal = dag.traverse(cover='paths')
        self.assertEqual([x.name for x in traversal], names)

        traversal = dag.traverse(cover='paths', depth=True)
        self.assertEqual([(x, y.name) for x,y in traversal], pairs)
开发者ID:jgalarowicz,项目名称:spack,代码行数:15,代码来源:spec_dag.py

示例15: test_dependents_and_dependencies_are_correct

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import normalize [as 别名]
    def test_dependents_and_dependencies_are_correct(self):
        spec = Spec('mpileaks',
                   Spec('callpath',
                        Spec('dyninst',
                             Spec('libdwarf',
                                  Spec('libelf')),
                             Spec('libelf')),
                        Spec('mpi')),
                   Spec('mpi'))

        self.check_links(spec)
        spec.normalize()
        self.check_links(spec)
开发者ID:jgalarowicz,项目名称:spack,代码行数:15,代码来源:spec_dag.py


注:本文中的spack.spec.Spec.normalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。