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


Python CopyPlugin.build方法代码示例

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


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

示例1: test_copy_plugin_copies

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_plugin_copies(self):
        self.mock_options.files = {
            'src': 'dst',
        }
        open('src', 'w').close()

        c = CopyPlugin('copy', self.mock_options)
        c.build()
        self.assertTrue(os.path.exists(os.path.join(self.dst_prefix, 'dst')))
开发者ID:asac,项目名称:snapcraft,代码行数:11,代码来源:test_plugin_copy.py

示例2: test_copy_plugin_handles_leading_slash

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_plugin_handles_leading_slash(self):
        self.mock_options.files = {
            'src': '/dst',
        }
        open('src', 'w').close()

        c = CopyPlugin('copy', self.mock_options)
        c.pull()
        c.build()
        self.assertTrue(os.path.exists(os.path.join(self.dst_prefix, 'dst')))
开发者ID:fallen,项目名称:snapcraft,代码行数:12,代码来源:test_plugin_copy.py

示例3: test_copy_plugin_handles_dot

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_plugin_handles_dot(self):
        self.mock_options.files = {
            'src': '.',
        }
        open('src', 'w').close()

        c = CopyPlugin('copy', self.mock_options, self.project_options)
        c.pull()
        c.build()
        self.assertTrue(os.path.exists(os.path.join(self.dst_prefix, 'src')))
开发者ID:blakerouse,项目名称:snapcraft,代码行数:12,代码来源:test_plugin_copy.py

示例4: test_copy_directories

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_directories(self):
        self.mock_options.files = {
            'dirs1': 'dir/dst',
        }
        os.mkdir('dirs1')
        file = os.path.join('dirs1', 'f')
        open(file, 'w').close()

        c = CopyPlugin('copy', self.mock_options)
        c.build()
        self.assertTrue(
            os.path.exists(os.path.join(self.dst_prefix, 'dir', 'dst', 'f')))
开发者ID:asac,项目名称:snapcraft,代码行数:14,代码来源:test_plugin_copy.py

示例5: test_copy_glob_does_not_match_anything

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_glob_does_not_match_anything(self):
        # ensure that a bad file causes a warning and fails the build even
        # if there is a good file last
        self.mock_options.files = {
            'src*': 'dst',
        }
        c = CopyPlugin('copy', self.mock_options)

        with self.assertRaises(EnvironmentError) as raised:
            c.build()

        self.assertEqual(raised.exception.__str__(), "no matches for 'src*'")
开发者ID:asac,项目名称:snapcraft,代码行数:14,代码来源:test_plugin_copy.py

示例6: test_copy_plugin_handles_leading_slash

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_plugin_handles_leading_slash(self):
        self.mock_options.files = {"src": "/dst"}
        c = CopyPlugin("copy", self.mock_options, self.project_options)

        # These directories are created by the pluginhandler
        os.makedirs(c.builddir)

        open(os.path.join(c.builddir, "src"), "w").close()

        c.build()

        self.assertTrue(os.path.exists(os.path.join(self.dst_prefix, "dst")))
开发者ID:mvo5,项目名称:snapcraft,代码行数:14,代码来源:test_copy.py

示例7: test_copy_plugin_creates_prefixes

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_plugin_creates_prefixes(self):
        self.useFixture(fixtures.FakeLogger())

        self.mock_options.files = {
            'src': 'dir/dst',
        }
        open('src', 'w').close()

        c = CopyPlugin('copy', self.mock_options)
        c.build()
        self.assertTrue(os.path.exists(os.path.join(self.dst_prefix,
                                                    'dir/dst')))
开发者ID:General-Beck,项目名称:snapcraft,代码行数:14,代码来源:test_copy_plugin.py

示例8: test_copy_symlinks_that_should_be_followed

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_symlinks_that_should_be_followed(self):
        self.mock_options.files = {"foo/*": "."}

        c = CopyPlugin("copy", self.mock_options, self.project_options)

        # These directories are created by the pluginhandler
        os.makedirs(c.builddir)

        os.makedirs(os.path.join(c.builddir, "foo", "bar"))
        with open(os.path.join(c.builddir, "foo", "file"), "w") as f:
            f.write("foo")

        with open("unsnapped", "w") as f:
            f.write("bar")

        symlinks = [
            # Links with an absolute path should be followed
            {
                "source": os.path.join(c.builddir, "foo", "file"),
                "link_name": os.path.join(c.builddir, "foo", "absolute"),
                "destination": os.path.join(c.installdir, "absolute"),
                "expected_contents": "foo",
            },
            # Links with a relative path that points outside of the snap
            # should also be followed
            {
                "source": "../../../../unsnapped",
                "link_name": os.path.join(c.builddir, "foo", "bad_relative"),
                "destination": os.path.join(c.installdir, "bad_relative"),
                "expected_contents": "bar",
            },
        ]

        for symlink in symlinks:
            os.symlink(symlink["source"], symlink["link_name"])

        c.build()

        with open(os.path.join(c.installdir, "file"), "r") as f:
            self.assertThat(f.read(), Equals("foo"))

        for symlink in symlinks:
            destination = symlink["destination"]
            self.assertFalse(
                os.path.islink(destination),
                "Expected {!r} to be a copy rather than a "
                "symlink".format(destination),
            )

            with open(destination, "r") as f:
                self.assertThat(f.read(), Equals(symlink["expected_contents"]))
开发者ID:mvo5,项目名称:snapcraft,代码行数:53,代码来源:test_copy.py

示例9: test_copy_plugin_handles_dot

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_plugin_handles_dot(self):
        self.mock_options.files = {
            'src': '.',
        }

        c = CopyPlugin('copy', self.mock_options, self.project_options)

        # These directories are created by the pluginhandler
        os.makedirs(c.builddir)

        open(os.path.join(c.builddir, 'src'), 'w').close()

        c.build()
        self.assertTrue(os.path.exists(os.path.join(self.dst_prefix, 'src')))
开发者ID:josepht,项目名称:snapcraft,代码行数:16,代码来源:test_copy.py

示例10: test_copy_symlinks_that_should_be_followed

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_symlinks_that_should_be_followed(self):
        self.mock_options.files = {'foo/*': '.'}

        c = CopyPlugin('copy', self.mock_options, self.project_options)

        # These directories are created by the pluginhandler
        os.makedirs(c.builddir)

        os.makedirs(os.path.join(c.builddir, 'foo', 'bar'))
        with open(os.path.join(c.builddir, 'foo', 'file'), 'w') as f:
            f.write('foo')

        with open('unsnapped', 'w') as f:
            f.write('bar')

        symlinks = [
            # Links with an absolute path should be followed
            {
                'source': os.path.join(c.builddir, 'foo', 'file'),
                'link_name': os.path.join(c.builddir, 'foo', 'absolute'),
                'destination': os.path.join(c.installdir, 'absolute'),
                'expected_contents': 'foo',
            },
            # Links with a relative path that points outside of the snap
            # should also be followed
            {
                'source': '../../../../unsnapped',
                'link_name': os.path.join(c.builddir, 'foo', 'bad_relative'),
                'destination': os.path.join(c.installdir, 'bad_relative'),
                'expected_contents': 'bar',
            },
        ]

        for symlink in symlinks:
            os.symlink(symlink['source'], symlink['link_name'])

        c.build()

        with open(os.path.join(c.installdir, 'file'), 'r') as f:
            self.assertEqual(f.read(), 'foo')

        for symlink in symlinks:
            destination = symlink['destination']
            self.assertFalse(os.path.islink(destination),
                             'Expected {!r} to be a copy rather than a '
                             'symlink'.format(destination))

            with open(destination, 'r') as f:
                self.assertEqual(f.read(), symlink['expected_contents'])
开发者ID:josepht,项目名称:snapcraft,代码行数:51,代码来源:test_copy.py

示例11: test_copy_plugin_any_missing_src_raises_exception

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_plugin_any_missing_src_raises_exception(self):
        # ensure that a bad file causes a warning and fails the build even
        # if there is a good file last
        self.mock_options.files = {
            'src': 'dst',
            'zzz': 'zzz',
        }
        open('zzz', 'w').close()
        c = CopyPlugin('copy', self.mock_options)

        with self.assertRaises(EnvironmentError) as raised:
            c.build()

        self.assertEqual(raised.exception.__str__(),
                         'file "src" missing')
开发者ID:General-Beck,项目名称:snapcraft,代码行数:17,代码来源:test_copy_plugin.py

示例12: test_copy_with_source_and_glob

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_with_source_and_glob(self):
        self.mock_options.source = 'src'
        self.mock_options.files = {'foo/*': 'baz/'}

        c = CopyPlugin('copy', self.mock_options, self.project_options)
        os.makedirs(os.path.join('src', 'foo'))
        open(os.path.join('src', 'foo', 'bar'), 'w').close()

        c.pull()
        self.assertTrue(
            os.path.isfile(os.path.join(c.sourcedir, 'foo', 'bar')))

        c.build()
        self.assertTrue(os.path.isfile(os.path.join(c.builddir, 'foo', 'bar')))
        self.assertTrue(
            os.path.isfile(os.path.join(c.installdir, 'baz', 'bar')))
开发者ID:blakerouse,项目名称:snapcraft,代码行数:18,代码来源:test_plugin_copy.py

示例13: test_copy_plugin_glob

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_plugin_glob(self):
        self.mock_options.files = {"*.txt": "."}

        c = CopyPlugin("copy", self.mock_options, self.project_options)

        # These directories are created by the pluginhandler
        os.makedirs(c.builddir)

        for filename in ("file-a.txt", "file-b.txt", "file-c.notxt"):
            with open(os.path.join(c.builddir, filename), "w") as datafile:
                datafile.write(filename)

        c.build()

        self.assertTrue(os.path.exists(os.path.join(self.dst_prefix, "file-a.txt")))
        self.assertTrue(os.path.exists(os.path.join(self.dst_prefix, "file-b.txt")))
        self.assertFalse(os.path.exists(os.path.join(self.dst_prefix, "file-c.notxt")))
开发者ID:mvo5,项目名称:snapcraft,代码行数:19,代码来源:test_copy.py

示例14: test_copy_directories

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_directories(self):
        self.mock_options.files = {"dirs1": "dir/dst"}

        c = CopyPlugin("copy", self.mock_options, self.project_options)

        # These directories are created by the pluginhandler
        os.makedirs(c.builddir)

        os.mkdir(os.path.join(c.builddir, "dirs1"))
        open(os.path.join(c.builddir, "dirs1", "f"), "w").close()
        os.makedirs(os.path.join(c.builddir, "foo", "bar"))

        c.pull()
        c.build()
        self.assertTrue(
            os.path.exists(os.path.join(self.dst_prefix, "dir", "dst", "f"))
        )
开发者ID:mvo5,项目名称:snapcraft,代码行数:19,代码来源:test_copy.py

示例15: test_copy_plugin_glob_with_folders

# 需要导入模块: from snapcraft.plugins.copy import CopyPlugin [as 别名]
# 或者: from snapcraft.plugins.copy.CopyPlugin import build [as 别名]
    def test_copy_plugin_glob_with_folders(self):
        self.mock_options.files = {
            'foo/*': '.',
        }

        os.makedirs(os.path.join('foo', 'directory'))
        open(os.path.join('foo', 'file1'), 'w').close()
        open(os.path.join('foo', 'directory', 'file2'), 'w').close()

        c = CopyPlugin('copy', self.mock_options, self.project_options)
        c.pull()
        c.build()

        self.assertTrue(os.path.isfile(os.path.join(c.installdir, 'file1')))
        self.assertTrue(os.path.isdir(os.path.join(c.installdir, 'directory')))
        self.assertTrue(os.path.isfile(
            os.path.join(c.installdir, 'directory', 'file2')))
开发者ID:blakerouse,项目名称:snapcraft,代码行数:19,代码来源:test_plugin_copy.py


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