• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python shared.create_dir函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中shared.create_dir函数的典型用法代码示例。如果您正苦于以下问题:Python create_dir函数的具体用法?Python create_dir怎么用?Python create_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_override

    def test_override(self):
        module_dir = shared.create_dir({'foo': 'bar'})
        self.write_yaml('''\
            cp module foo:
                path: {}

            imports:
                foo: ./
            ''', module_dir)
        override_dir = shared.create_dir({'foo': 'override'})
        # Set the override.
        run_peru_command(['override', 'add', 'foo', override_dir],
                         self.test_dir)
        # Confirm that the override is configured.
        output = run_peru_command(['override'], self.test_dir)
        self.assertEqual(output, 'foo: {}\n'.format(override_dir))
        # Make sure 'override list' gives the same output as 'override'.
        output = run_peru_command(['override', 'list'], self.test_dir)
        self.assertEqual(output, 'foo: {}\n'.format(override_dir))
        # Run the sync and confirm that the override worked.
        self.do_integration_test(['sync'], {'foo': 'override'})
        # Delete the override.
        run_peru_command(['override', 'delete', 'foo'], self.test_dir)
        # Confirm that the override was deleted.
        output = run_peru_command(['override'], self.test_dir)
        self.assertEqual(output, '')
        # Rerun the sync and confirm the original content is back.
        self.do_integration_test(['sync'], {'foo': 'bar'})
开发者ID:eramosfigueroa,项目名称:peru-1,代码行数:28,代码来源:test_sync.py


示例2: test_override

    def test_override(self):
        module_dir = shared.create_dir({'foo': 'bar'})
        self.write_yaml('''\
            cp module foo:
                path: {}

            imports:
                foo: ./
            ''', module_dir)
        override_dir = shared.create_dir({'foo': 'override'})
        # Set the override.
        run_peru_command(['override', 'add', 'foo', override_dir],
                         self.test_dir)
        # Confirm that the override is configured.
        output = run_peru_command(['override'], self.test_dir)
        self.assertEqual(output, 'foo: {}\n'.format(override_dir))
        # Make sure 'override list' gives the same output as 'override'.
        output = run_peru_command(['override', 'list'], self.test_dir)
        self.assertEqual(output, 'foo: {}\n'.format(override_dir))
        # Run the sync with --no-overrides and confirm nothing changes. Also
        # check that there's no overrides-related output.
        output = self.do_integration_test(['sync', '--no-overrides'],
                                          {'foo': 'bar'})
        self.assertNotIn('overrides', output)
        # Now run the sync normally and confirm that the override worked. Also
        # confirm that we mentioned the override in output.
        output = self.do_integration_test(['sync'], {'foo': 'override'})
        self.assertIn('overrides', output)
        # Delete the override.
        run_peru_command(['override', 'delete', 'foo'], self.test_dir)
        # Confirm that the override was deleted.
        output = run_peru_command(['override'], self.test_dir)
        self.assertEqual(output, '')
        # Rerun the sync and confirm the original content is back.
        self.do_integration_test(['sync'], {'foo': 'bar'})
开发者ID:emgee,项目名称:peru,代码行数:35,代码来源:test_sync.py


示例3: test_import_with_gitignore

 def test_import_with_gitignore(self):
     # Make sure our git imports don't get confused by .gitignore files.
     new_content = {"fee/fi": "fo fum", ".gitignore": "fee/"}
     new_tree = self.cache.import_tree(shared.create_dir(new_content))
     export_dir = shared.create_dir()
     self.cache.export_tree(new_tree, export_dir)
     assert_contents(export_dir, new_content)
开发者ID:Arvindhm,项目名称:peru,代码行数:7,代码来源:test_cache.py


示例4: setUp

 def setUp(self):
     self.cache_dir = shared.create_dir()
     self.cache = cache.Cache(self.cache_dir)
     self.content = {'a': 'foo', 'b/c': 'bar'}
     self.content_dir = shared.create_dir(self.content)
     self.content_tree = self.cache.import_tree(self.content_dir)
     self.entries = self.cache.ls_tree(self.content_tree, recursive=True)
开发者ID:enzochiau,项目名称:peru,代码行数:7,代码来源:test_rule.py


示例5: test_identical_plugin_cache_fields

    def test_identical_plugin_cache_fields(self):
        # Plugins that use caching also need to avoid running in parallel, if
        # their cache directories are the same. The noop_cache plugin (created
        # for this test) uses the path field (but not the nonce field) in its
        # plugin cache key. Check that these two modules are not fetched in
        # parallel, even though their module fields aren't exactly the same.
        foo = shared.create_dir()
        peru_yaml = dedent('''\
            imports:
                foo1: ./
                foo2: ./

            noop_cache module foo1:
                path: {}
                # nonce is ignored, but it makes foo1 different from foo2 as
                # far as the module cache is concerned
                nonce: '1'

            noop_cache module foo2:
                path: {}
                nonce: '2'
            '''.format(foo, foo))
        test_dir = shared.create_dir({'peru.yaml': peru_yaml})
        shared.run_peru_command(['sync'], test_dir)
        assert_parallel(1)
开发者ID:Arvindhm,项目名称:peru,代码行数:25,代码来源:test_parallelism.py


示例6: setUp

 def setUp(self):
     self.cache_dir = shared.create_dir()
     self.cache = yield from cache.Cache(self.cache_dir)
     self.content = {"a": "foo", "b/c": "bar"}
     self.content_dir = shared.create_dir(self.content)
     self.content_tree = yield from self.cache.import_tree(self.content_dir)
     self.entries = yield from self.cache.ls_tree(self.content_tree, recursive=True)
开发者ID:emgee,项目名称:peru,代码行数:7,代码来源:test_rule.py


示例7: test_import_with_gitignore

 def test_import_with_gitignore(self):
     # Make sure our git imports don't get confused by .gitignore files.
     new_content = {'fee/fi': 'fo fum', '.gitignore': 'fee/'}
     new_tree = yield from self.cache.import_tree(create_dir(new_content))
     export_dir = create_dir()
     yield from self.cache.export_tree(new_tree, export_dir)
     assert_contents(export_dir, new_content)
开发者ID:jmbrads22,项目名称:peru,代码行数:7,代码来源:test_cache.py


示例8: test_keyval

 def test_keyval(self):
     root = shared.create_dir()
     tmp_dir = shared.create_dir()
     keyval = KeyVal(root, tmp_dir)
     key = "mykey"
     # keyval should be empty
     self.assertFalse(key in keyval)
     self.assertSetEqual(set(keyval), set())
     # set a key
     keyval[key] = "myval"
     self.assertEqual(keyval[key], "myval")
     self.assertTrue(key in keyval)
     self.assertSetEqual(set(keyval), {key})
     # overwrite the value
     keyval[key] = "anotherval"
     self.assertEqual(keyval[key], "anotherval")
     # instantiate a second keyval on the same dir, should have same content
     another_keyval = KeyVal(root, tmp_dir)
     self.assertTrue(key in another_keyval)
     self.assertEqual(another_keyval[key], "anotherval")
     self.assertSetEqual(set(another_keyval), {key})
     # test deletions
     del keyval[key]
     self.assertFalse(key in keyval)
     self.assertFalse(key in another_keyval)
开发者ID:emgee,项目名称:peru,代码行数:25,代码来源:test_keyval.py


示例9: test_flags_override_vars

 def test_flags_override_vars(self):
     flag_cache_dir = shared.create_dir()
     env_cache_dir = shared.create_dir()
     shared.run_peru_command(['--cache-dir', flag_cache_dir, 'sync'],
                             self.cwd,
                             env={'PERU_CACHE_DIR': env_cache_dir})
     self.assert_success(self.project_dir, self.state_dir, flag_cache_dir)
开发者ID:emgee,项目名称:peru,代码行数:7,代码来源:test_paths.py


示例10: test_import_module_defined_in_another_module

    def test_import_module_defined_in_another_module(self):
        # Project B contains project A
        dir_a = shared.create_dir({'afile': 'stuff'})
        dir_b = shared.create_dir()
        # Create the peru.yaml file for B.
        self.write_yaml('''\
            cp module a:
                path: {}
            ''', dir_a, dir=dir_b)
        # Now create the peru.yaml file in the actual test project.
        self.write_yaml('''\
            imports:
                b.a: a_via_b/

            cp module b:
                path: {}
            ''', dir_b)
        self.do_integration_test(['sync'], {'a_via_b/afile': 'stuff'})
        # Test the error message from an invalid module.
        self.write_yaml('''\
            imports:
                b.missing_module: some_path

            cp module b:
                path: {}
            ''', dir_b)
        try:
            self.do_integration_test(['sync'], {})
        except peru.error.PrintableError as e:
            assert 'b.missing_module' in e.message
        else:
            assert False, 'should throw invalid module error'
开发者ID:oconnor663,项目名称:peru,代码行数:32,代码来源:test_sync.py


示例11: test_touched_file

    def test_touched_file(self):
        # Bumping the mtime on a file makes it appear dirty to `git
        # diff-files`. However, when the index is refreshed with `git
        # update-index`, the dirtiness should go away. This test guarantees
        # that we do that refresh, both with and without a cached index file.
        # Note that because the index file only has an mtime resolution of 1
        # second, we have to artificially inflate the mtime to guarantee that
        # the file will actually appear dirty.
        export_dir = create_dir()
        a_path = os.path.join(export_dir, 'a')
        t = time.time()

        def bump_mtime_one_minute():
            nonlocal t
            t += 60  # Add a whole minute to the mtime we set.
            os.utime(a_path, (t, t))

        # Do the first export.
        yield from self.cache.export_tree(self.content_tree, export_dir)
        # Touch a and rerun the export with no cached index.
        bump_mtime_one_minute()
        yield from self.cache.export_tree(
            self.content_tree, export_dir, previous_tree=self.content_tree)
        # Create a cached index file.
        index_dir = create_dir()
        index_file = os.path.join(index_dir, 'test_index_file')
        yield from self.cache.export_tree(
            self.content_tree, export_dir, previous_tree=self.content_tree,
            previous_index_file=index_file)
        # Finally, touch a again and rerun the export using the cached index.
        bump_mtime_one_minute()
        yield from self.cache.export_tree(
            self.content_tree, export_dir, previous_tree=self.content_tree,
            previous_index_file=index_file)
开发者ID:jmbrads22,项目名称:peru,代码行数:34,代码来源:test_cache.py


示例12: setUp

    def setUp(self):
        self.cache_dir = create_dir()
        self.cache = Cache(self.cache_dir)

        # These tests use this simple one-file tree as module contents.
        content = {'a': 'a'}
        content_dir = create_dir(content)
        self.content_tree = self.cache.import_tree(content_dir)
开发者ID:Arvindhm,项目名称:peru,代码行数:8,代码来源:test_merge.py


示例13: setUp

 async def setUp(self):
     self.cache_dir = shared.create_dir()
     self.cache = await cache.Cache(self.cache_dir)
     # Include a leading colon to test that we prepend ./ to pathspecs.
     self.content = {'a': 'foo', 'b/c': 'bar', COLON + 'd': 'baz'}
     self.content_dir = shared.create_dir(self.content)
     self.content_tree = await self.cache.import_tree(self.content_dir)
     self.entries = await self.cache.ls_tree(
         self.content_tree, recursive=True)
开发者ID:buildinspace,项目名称:peru,代码行数:9,代码来源:test_rule.py


示例14: setUp

 def setUp(self):
     self.cache = peru.cache.Cache(shared.create_dir())
     self.content = {
         "a": "foo",
         "b/c": "bar",
         "b/d": "baz",
     }
     self.content_dir = shared.create_dir(self.content)
     self.content_tree = self.cache.import_tree(self.content_dir)
开发者ID:Arvindhm,项目名称:peru,代码行数:9,代码来源:test_cache.py


示例15: setUp

 async def setUp(self):
     self.cache = await peru.cache.Cache(create_dir())
     self.content = {
         'a': 'foo',
         'b/c': 'bar',
         'b/d': 'baz',
     }
     self.content_dir = create_dir(self.content)
     self.content_tree = await self.cache.import_tree(self.content_dir)
开发者ID:buildinspace,项目名称:peru,代码行数:9,代码来源:test_cache.py


示例16: setUp

 def setUp(self):
     self.cache = yield from peru.cache.Cache(create_dir())
     self.content = {
         'a': 'foo',
         'b/c': 'bar',
         'b/d': 'baz',
     }
     self.content_dir = create_dir(self.content)
     self.content_tree = yield from self.cache.import_tree(self.content_dir)
开发者ID:jmbrads22,项目名称:peru,代码行数:9,代码来源:test_cache.py


示例17: test_setting_all_flags

 def test_setting_all_flags(self):
     cwd = shared.create_dir()
     sync_dir = shared.create_dir()
     state_dir = shared.create_dir()
     cache_dir = shared.create_dir()
     shared.run_peru_command(
         ['--file', self.peru_file, '--sync-dir', sync_dir,
          '--state-dir', state_dir, '--cache-dir', cache_dir, 'sync'],
         cwd)
     self.assert_success(sync_dir, state_dir, cache_dir)
开发者ID:emgee,项目名称:peru,代码行数:10,代码来源:test_paths.py


示例18: test_import_with_files

 def test_import_with_files(self):
     all_content = {'foo': '',
                    'bar': '',
                    'baz/bing': ''}
     test_dir = create_dir(all_content)
     tree = self.cache.import_tree(test_dir, picks=['foo', 'baz'])
     expected_content = {'foo': '',
                         'baz/bing': ''}
     out_dir = create_dir()
     self.cache.export_tree(tree, out_dir)
     assert_contents(out_dir, expected_content)
开发者ID:enzochiau,项目名称:peru,代码行数:11,代码来源:test_cache.py


示例19: test_merge_with_deep_prefix

 def test_merge_with_deep_prefix(self):
     '''This test was inspired by a bug on Windows where we would give git a
     backslash-separated merge prefix, even though git demands forward slash
     as a path separator.'''
     content = {'file': 'stuff'}
     content_dir = create_dir(content)
     tree = yield from self.cache.import_tree(content_dir)
     prefixed_tree = yield from self.cache.merge_trees(None, tree, 'a/b/')
     export_dir = create_dir()
     yield from self.cache.export_tree(prefixed_tree, export_dir)
     assert_contents(export_dir, {'a/b/file': 'stuff'})
开发者ID:jmbrads22,项目名称:peru,代码行数:11,代码来源:test_cache.py


示例20: setUp

 def setUp(self):
     self.content = {"some": "stuff", "foo/bar": "baz"}
     self.content_dir = shared.create_dir(self.content)
     self.cache_root = shared.create_dir()
     self.plugin_context = plugin.PluginContext(
         cwd='.',
         plugin_cache_root=self.cache_root,
         plugin_paths=(),
         parallelism_semaphore=asyncio.BoundedSemaphore(
             plugin.DEFAULT_PARALLEL_FETCH_LIMIT),
         plugin_cache_locks=defaultdict(asyncio.Lock))
开发者ID:mgartner,项目名称:peru,代码行数:11,代码来源:test_plugins.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python shared.path_from_root函数代码示例发布时间:2022-05-27
下一篇:
Python shared.broadcastToSendDataQueues函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap