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

Python parser.main函数代码示例

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

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



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

示例1: test_remote_after_parts_unordered

    def test_remote_after_parts_unordered(self, mock_get_origin_data):
        _create_example_output("""
---
maintainer: Marco Trevisan <[email protected]>
origin: lp:snapcraft-parser-example
description: parent part that depends on child
parts: [parent]
---
maintainer: John Doe <[email protected]>
origin: lp:snapcraft-parser-example
description: example part on which parent depends on
parts: [child]
""")
        parts = OrderedDict()

        parent_part = OrderedDict()
        parent_part['description'] = 'example part on which parent depends on'
        parent_part['maintainer'] = 'Marco Trevisan <[email protected]>'
        parent_part['plugin'] = 'dump'
        parent_part['source'] = 'lp:project'
        parent_part['after'] = ['child']
        parts['parent'] = parent_part

        child_part = OrderedDict()
        child_part['description'] = 'parent part that depends on child'
        child_part['maintainer'] = 'John Doe <[email protected]>'
        child_part['plugin'] = 'dump'
        child_part['source'] = 'lp:project'
        parts['child'] = child_part

        mock_get_origin_data.return_value = {
            'parts': parts,
        }
        main(['--index', TEST_OUTPUT_PATH])
        self.assertEqual(2, _get_part_list_count())
开发者ID:squidsoup,项目名称:snapcraft,代码行数:35,代码来源:test_parser.py


示例2: test_carriage_returns

    def test_carriage_returns(self, mock_get_origin_data):
        """Test carriage returns in the wiki."""

        fake_logger = fixtures.FakeLogger(level=logging.ERROR)
        self.useFixture(fake_logger)

        _create_example_output("""\r
---
maintainer: John Doe <[email protected]>
origin: lp:snapcraft-parser-example
description: example main\r
parts: [main]\r
---
maintainer: Jim Doe <[email protected]>
origin: lp:snapcraft-parser-example
description: example main duplicate
parts: [main]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:project',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        part = _get_part('main')
        self.assertEqual('example main', part['description'])

        self.assertEqual(1, _get_part_list_count())
开发者ID:squidsoup,项目名称:snapcraft,代码行数:33,代码来源:test_parser.py


示例3: test_main_slash_warning

    def test_main_slash_warning(self, mock_get_origin_data):
        fake_logger = fixtures.FakeLogger(level=logging.WARN)
        self.useFixture(fake_logger)

        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main/a]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main/a": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(1))

        m = 'DEPRECATED: Found a "/" in the name of the {!r} part'.format("main/a")
        self.assertTrue(
            m in fake_logger.output, "Missing slash deprecation warning in output"
        )
开发者ID:mvo5,项目名称:snapcraft,代码行数:29,代码来源:test_parser.py


示例4: test_wiki_with_fake_origin

    def test_wiki_with_fake_origin(self):

        fixture = fixture_setup.FakePartsWikiOrigin()
        self.useFixture(fixture)
        origin_url = fixture.fake_parts_wiki_origin_fixture.url

        _create_example_output("""
---
maintainer: John Doe <[email protected]>
origin: {origin_url}
description: example
parts: [somepart]
""".format(origin_url=origin_url))

        origin_dir = os.path.join(parser._get_base_dir(),
                                  _encode_origin(origin_url))
        os.makedirs(origin_dir, exist_ok=True)

        # Create a fake snapcraft.yaml for _get_origin_data() to parse
        with open(os.path.join(origin_dir, 'snapcraft.yaml'),
                  'w') as fp:
            text = requests.get(origin_url).text
            fp.write(text)

        main(['--debug', '--index', TEST_OUTPUT_PATH])
        self.assertEqual(1, _get_part_list_count())
        part = _get_part('somepart')
        self.assertTrue(part)
开发者ID:squidsoup,项目名称:snapcraft,代码行数:28,代码来源:test_parser.py


示例5: test_missing_snapcraft_yaml

    def test_missing_snapcraft_yaml(self):

        fixture = fixture_setup.FakePartsWikiOrigin()
        self.useFixture(fixture)
        origin_url = fixture.fake_parts_wiki_origin_fixture.url

        fake_logger = fixtures.FakeLogger(level=logging.ERROR)
        self.useFixture(fake_logger)

        _create_example_output(
            """
---
maintainer: John Doe <[email protected]>
origin: {origin_url}
description: example
parts: [somepart]
""".format(
                origin_url=origin_url
            )
        )

        main(["--debug", "--index", TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(0))

        self.assertTrue(
            "1 wiki errors found" in fake_logger.output,
            "Missing invalid wiki entry info in output",
        )
开发者ID:mvo5,项目名称:snapcraft,代码行数:28,代码来源:test_parser.py


示例6: test_descriptions_get_block_quotes

    def test_descriptions_get_block_quotes(self, mock_get_origin_data):
        output = """
---
maintainer: John Doe <[email protected]>
origin: lp:snapcraft-parser-example
description: |
  example

  Usage:
    blahblahblah
parts: [main]
"""
        _create_example_output(output)
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])
        with open('snap-parts.yaml') as fp:
            data = fp.read()
            self.assertNotIn('description: "', data)
            self.assertIn('description: |', data)
        self.assertEqual(1, _get_part_list_count())
开发者ID:squidsoup,项目名称:snapcraft,代码行数:28,代码来源:test_parser.py


示例7: test_source_with_local_source_subdir_part_origin

    def test_source_with_local_source_subdir_part_origin(
            self, mock_get_origin_data):
        """Test a wiki entry with a source with a local source-subdir part."""
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': '.',
                    'source-subdir': 'local',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        self.assertEqual(1, _get_part_list_count())
        part = _get_part('main')
        self.assertNotEqual('.', part['source'])
        self.assertEqual('local', part['source-subdir'])
        self.assertEqual(6, len(part.keys()))
开发者ID:squidsoup,项目名称:snapcraft,代码行数:27,代码来源:test_parser.py


示例8: test_multiple_part_origin

    def test_multiple_part_origin(self, mock_get_origin_data):
        """Test a wiki entry with multiple origin parts."""
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: ['main', 'subpart']
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                    'after': ['subpart'],
                },
                'subpart': {
                    'source': 'lp:somethingelse',
                    'plugin': 'copy',
                    'files': ['subfile2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        self.assertEqual(2, _get_part_list_count())
开发者ID:squidsoup,项目名称:snapcraft,代码行数:27,代码来源:test_parser.py


示例9: test_output_parameter

    def test_output_parameter(self, mock_get_origin_data):
        """Test a wiki entry with multiple origin parts."""
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }

        filename = 'parts.yaml'

        main(['--debug', '--index', TEST_OUTPUT_PATH, '--output', filename])

        self.assertEqual(1, _get_part_list_count(filename))
        self.assertTrue(os.path.exists(filename))
开发者ID:squidsoup,项目名称:snapcraft,代码行数:25,代码来源:test_parser.py


示例10: test_main_slash_warning

    def test_main_slash_warning(self, mock_get_origin_data):
        fake_logger = fixtures.FakeLogger(level=logging.WARN)
        self.useFixture(fake_logger)

        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main/a]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main/a': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])
        self.assertEqual(1, _get_part_list_count())

        m = 'DEPRECATED: Found a "/" in the name of the {!r} part'.format(
            'main/a')
        self.assertTrue(m in fake_logger.output,
                        'Missing slash deprecation warning in output')
开发者ID:squidsoup,项目名称:snapcraft,代码行数:27,代码来源:test_parser.py


示例11: test_main_valid_with_default_index

 def test_main_valid_with_default_index(self, mock_urlopen):
     class FakeResponse:
         def read(self):
             return b''
     mock_urlopen.return_value = FakeResponse()
     main(['--debug'])
     self.assertEqual(0, _get_part_list_count())
开发者ID:squidsoup,项目名称:snapcraft,代码行数:7,代码来源:test_parser.py


示例12: test_multiple_part_origin

    def test_multiple_part_origin(self, mock_get_origin_data):
        """Test a wiki entry with multiple origin parts."""
        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: ['main', 'subpart']
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                    "after": ["subpart"],
                },
                "subpart": {
                    "source": "lp:somethingelse",
                    "plugin": "copy",
                    "files": ["subfile2"],
                },
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        self.assertThat(_get_part_list_count(), Equals(2))
开发者ID:mvo5,项目名称:snapcraft,代码行数:29,代码来源:test_parser.py


示例13: test_remote_after_parts_unordered

    def test_remote_after_parts_unordered(self, mock_get_origin_data):
        _create_example_output(
            """
---
maintainer: Marco Trevisan <[email protected]>
origin: lp:snapcraft-parser-example
description: parent part that depends on child
parts: [parent]
---
maintainer: John Doe <[email protected]>
origin: lp:snapcraft-parser-example
description: example part on which parent depends on
parts: [child]
"""
        )
        parts = OrderedDict()

        parent_part = OrderedDict()
        parent_part["description"] = "example part on which parent depends on"
        parent_part["maintainer"] = "Marco Trevisan <[email protected]>"
        parent_part["plugin"] = "dump"
        parent_part["source"] = "lp:project"
        parent_part["after"] = ["child"]
        parts["parent"] = parent_part

        child_part = OrderedDict()
        child_part["description"] = "parent part that depends on child"
        child_part["maintainer"] = "John Doe <[email protected]>"
        child_part["plugin"] = "dump"
        child_part["source"] = "lp:project"
        parts["child"] = child_part

        mock_get_origin_data.return_value = {"parts": parts}
        main(["--index", TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(2))
开发者ID:mvo5,项目名称:snapcraft,代码行数:35,代码来源:test_parser.py


示例14: test_wiki_interactions_with_fake_with_slashes

    def test_wiki_interactions_with_fake_with_slashes(
            self, mock_get_origin_data):

        fixture = fixture_setup.FakePartsWikiWithSlashes()
        self.useFixture(fixture)

        mock_get_origin_data.return_value = {
            'parts': {
                'curl/a': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
                'curl-a': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index',
              fixture.fake_parts_wiki_with_slashes_fixture.url])
        self.assertEqual(2, _get_part_list_count())

        part1 = _get_part('curl/a')
        self.assertTrue(part1)

        part2 = _get_part('curl-a')
        self.assertTrue(part2)
开发者ID:squidsoup,项目名称:snapcraft,代码行数:29,代码来源:test_parser.py


示例15: test_carriage_returns

    def test_carriage_returns(self, mock_get_origin_data):
        """Test carriage returns in the wiki."""

        fake_logger = fixtures.FakeLogger(level=logging.ERROR)
        self.useFixture(fake_logger)

        _create_example_output(
            """\r
---
maintainer: John Doe <[email protected]>
origin: lp:snapcraft-parser-example
description: example main\r
parts: [main]\r
---
maintainer: Jim Doe <[email protected]>
origin: lp:snapcraft-parser-example
description: example main duplicate
parts: [main]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:project",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        part = _get_part("main")
        self.assertThat(part["description"], Equals("example main"))

        self.assertThat(_get_part_list_count(), Equals(1))
开发者ID:mvo5,项目名称:snapcraft,代码行数:35,代码来源:test_parser.py


示例16: test_descriptions_get_block_quotes

    def test_descriptions_get_block_quotes(self, mock_get_origin_data):
        output = """
---
maintainer: John Doe <[email protected]>
origin: lp:snapcraft-parser-example
description: |
  example

  Usage:
    blahblahblah
parts: [main]
"""
        _create_example_output(output)
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])
        with open("snap-parts.yaml") as fp:
            data = fp.read()
            self.assertNotIn('description: "', data)
            self.assertIn("description: |", data)
        self.assertThat(_get_part_list_count(), Equals(1))
开发者ID:mvo5,项目名称:snapcraft,代码行数:28,代码来源:test_parser.py


示例17: test_wiki_interactions_with_fake_with_slashes

    def test_wiki_interactions_with_fake_with_slashes(self, mock_get_origin_data):

        fixture = fixture_setup.FakePartsWikiWithSlashes()
        self.useFixture(fixture)

        mock_get_origin_data.return_value = {
            "parts": {
                "curl/a": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                },
                "curl-a": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                },
            }
        }
        main(["--debug", "--index", fixture.fake_parts_wiki_with_slashes_fixture.url])
        self.assertThat(_get_part_list_count(), Equals(2))

        part1 = _get_part("curl/a")
        self.assertTrue(part1)

        part2 = _get_part("curl-a")
        self.assertTrue(part2)
开发者ID:mvo5,项目名称:snapcraft,代码行数:27,代码来源:test_parser.py


示例18: test_n_documents

    def test_n_documents(self, mock_get_origin_data):
        """Test 2 wiki entries."""
        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main2]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:project",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                },
                "main2": {
                    "source": "lp:project",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                },
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        self.assertThat(_get_part_list_count(), Equals(2))
开发者ID:mvo5,项目名称:snapcraft,代码行数:33,代码来源:test_parser.py


示例19: test_source_with_local_source_subdir_part_origin

    def test_source_with_local_source_subdir_part_origin(self, mock_get_origin_data):
        """Test a wiki entry with a source with a local source-subdir part."""
        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": ".",
                    "source-subdir": "local",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        self.assertThat(_get_part_list_count(), Equals(1))
        part = _get_part("main")
        self.assertNotEqual(".", part["source"])
        self.assertThat(part["source-subdir"], Equals("local"))
        self.assertThat(len(part.keys()), Equals(6))
开发者ID:mvo5,项目名称:snapcraft,代码行数:28,代码来源:test_parser.py


示例20: test_output_parameter

    def test_output_parameter(self, mock_get_origin_data):
        """Test a wiki entry with multiple origin parts."""
        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }

        filename = "parts.yaml"

        main(["--debug", "--index", TEST_OUTPUT_PATH, "--output", filename])

        self.assertThat(_get_part_list_count(filename), Equals(1))
        self.assertTrue(os.path.exists(filename))
开发者ID:mvo5,项目名称:snapcraft,代码行数:27,代码来源:test_parser.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python main.main函数代码示例发布时间:2022-05-27
下一篇:
Python meta.create_snap_packaging函数代码示例发布时间: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