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


Python Manifest.merge方法代码示例

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


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

示例1: test_nonrecursive

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import merge [as 别名]
    def test_nonrecursive(self):
        m1 = self.mfp.build(["bar", "foo", "  bar", "  foo"])
        m2 = self.mfp.build(["foo", "  foo", "xyzzy"])
        m3 = self.mfp.build(["foo", "  bar", "    baz", "  foo", "    foo"])
        self.assertEqual(list(Manifest.merge(m1, m2, m3)), [
            ("bar", None, None),
            ("foo", "foo", "foo"),
            ("foo/bar", None, "foo/bar"),
            (None, None, "foo/bar/baz"),
            ("foo/foo", "foo/foo", "foo/foo"),
            (None, None, "foo/foo/foo"),
            (None, "xyzzy", None)])

        # now without recursion
        self.assertEqual(list(Manifest.merge(m1, m2, m3, recursive = False)), [
            ("bar", None, None),
            ("foo", "foo", "foo"),
            (None, "xyzzy", None)])

        # and finally with selective recursion (only recurse into "foo"s)
        actual = []
        gen = Manifest.merge(m1, m2, m3, recursive = False)
        try:
            t = next(gen)
            while True:
                actual.append(t)
                paths = [p for p in t if p is not None]
                self.assertTrue(paths)
                path = paths[0]
                self.assertEqual([path] * len(paths), paths)
                try:
                    last_component = path.rsplit("/", 1)[1]
                except:
                    last_component = path
                if last_component == "foo":
                    t = gen.send(True)
                else:
                    t = next(gen)
        except StopIteration:
            pass

        self.assertEqual(actual, [
            ("bar", None, None),
            ("foo", "foo", "foo"),
            ("foo/bar", None, "foo/bar"),
            ("foo/foo", "foo/foo", "foo/foo"),
            (None, None, "foo/foo/foo"),
            (None, "xyzzy", None)])
开发者ID:jherland,项目名称:manifest,代码行数:50,代码来源:test_Manifest_merge_diff.py

示例2: test_custom_key

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import merge [as 别名]
 def test_custom_key(self):
     m1 = self.mfp.build(["1foo", "2bar", "3baz"])
     m2 = self.mfp.build(["abc", "def", "ghi"])
     m3 = self.mfp.build(["123", "456", "789"])
     self.assertEqual(
         list(Manifest.merge(m1, m2, m3, key = lambda px: True)), [
             ("1foo", "abc", "123"),
             ("2bar", "def", "456"),
             ("3baz", "ghi", "789")])
开发者ID:jherland,项目名称:manifest,代码行数:11,代码来源:test_Manifest_merge_diff.py

示例3: test_empty_subdir_vs_nonepty_subdir

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import merge [as 别名]
 def test_empty_subdir_vs_nonepty_subdir(self):
     m1 = Manifest_from_walking_unpacked_tar("file_and_empty_subdir.tar")
     m2 = Manifest_from_walking_unpacked_tar("file_and_subdir.tar")
     self.assertEqual(list(Manifest.merge(m1, m2)), [
         ("file", "file"), ("subdir", "subdir"), (None, "subdir/foo")])
开发者ID:jherland,项目名称:manifest,代码行数:7,代码来源:test_Manifest_merge_diff.py

示例4: test_three_mixed_singles

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import merge [as 别名]
 def test_three_mixed_singles(self):
     m1, m2, m3 = map(self.mfp.build, (["foo"], ["bar"], ["foo"]))
     self.assertEqual(list(Manifest.merge(m1, m2, m3)), [
         (None, "bar", None), ("foo", None, "foo")])
开发者ID:jherland,项目名称:manifest,代码行数:6,代码来源:test_Manifest_merge_diff.py

示例5: test_three_with_overlap

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import merge [as 别名]
 def test_three_with_overlap(self):
     ms = map(self.mfp.build,
              (["foo", "same"], ["bar", "same"], ["baz", "same"]))
     self.assertEqual(list(Manifest.merge(*ms)), [
         (None, "bar", None), (None, None, "baz"), ("foo", None, None),
         ("same", "same", "same")])
开发者ID:jherland,项目名称:manifest,代码行数:8,代码来源:test_Manifest_merge_diff.py

示例6: test_single_file_x2

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import merge [as 别名]
 def test_single_file_x2(self):
     m1 = Manifest_from_walking_unpacked_tar("single_file.tar")
     m2 = self.mfp.build(["foo"])
     self.assertEqual(list(Manifest.merge(m1, m2)), [("foo", "foo")])
开发者ID:jherland,项目名称:manifest,代码行数:6,代码来源:test_Manifest_merge_diff.py

示例7: test_one_single_file

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import merge [as 别名]
 def test_one_single_file(self):
     m = Manifest_from_walking_unpacked_tar("single_file.tar")
     self.assertEqual(list(Manifest.merge(m)), [("foo",)])
开发者ID:jherland,项目名称:manifest,代码行数:5,代码来源:test_Manifest_merge_diff.py

示例8: test_two_empties

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import merge [as 别名]
 def test_two_empties(self):
     m1, m2 = Manifest(), Manifest_from_walking_unpacked_tar("empty.tar")
     self.assertEqual(list(Manifest.merge(m1, m2)), [])
开发者ID:jherland,项目名称:manifest,代码行数:5,代码来源:test_Manifest_merge_diff.py

示例9: test_one_empty

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import merge [as 别名]
 def test_one_empty(self):
     m = Manifest()
     self.assertEqual(list(Manifest.merge(m)), [])
开发者ID:jherland,项目名称:manifest,代码行数:5,代码来源:test_Manifest_merge_diff.py

示例10: test_nothing

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import merge [as 别名]
 def test_nothing(self):
     self.assertEqual(list(Manifest.merge()), [])
开发者ID:jherland,项目名称:manifest,代码行数:4,代码来源:test_Manifest_merge_diff.py


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