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


Python manifestparser.ManifestParser类代码示例

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


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

示例1: test_parent_inheritance

    def test_parent_inheritance(self):
        """
        Test parent manifest variable inheritance
        Specifically tests that inherited variables from parent includes
        properly propagate downstream
        """
        parent_example = os.path.join(here, 'parent', 'level_1', 'level_2',
                                      'level_3', 'level_3.ini')
        parser = ManifestParser(manifests=(parent_example,))

        # Parent manifest test should not be included
        self.assertEqual(parser.get('name'),
                         ['test_3'])
        self.assertEqual([(test['name'], os.path.basename(test['manifest']))
                          for test in parser.tests],
                         [('test_3', 'level_3.ini')])

        # DEFAULT values should be the ones from level 1
        self.assertEqual(parser.get('name', x='level_1'),
                         ['test_3'])

        # Write the output to a manifest:
        buffer = StringIO()
        parser.write(fp=buffer, global_kwargs={'x': 'level_1'})
        self.assertEqual(buffer.getvalue().strip(),
                         '[DEFAULT]\nx = level_1\n\n[test_3]\nsubsuite =')
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:26,代码来源:test_manifestparser.py

示例2: install_from_manifest

    def install_from_manifest(self, filepath):
        """
        Installs addons from a manifest
        :param filepath: path to the manifest of addons to install
        """
        manifest = ManifestParser()
        manifest.read(filepath)
        addons = manifest.get()

        for addon in addons:
            if '://' in addon['path'] or os.path.exists(addon['path']):
                self.install_from_path(addon['path'])
                continue

            # No path specified, try to grab it off AMO
            locale = addon.get('amo_locale', 'en_US')
            query = 'https://services.addons.mozilla.org/' + locale + '/firefox/api/' + AMO_API_VERSION + '/'
            if 'amo_id' in addon:
                query += 'addon/' + addon['amo_id']                 # this query grabs information on the addon base on its id
            else:
                query += 'search/' + addon['name'] + '/default/1'   # this query grabs information on the first addon returned from a search
            install_path = AddonManager.get_amo_install_path(query)
            self.install_from_path(install_path)

        self.installed_manifests.append(filepath)
开发者ID:JasonGross,项目名称:mozjs,代码行数:25,代码来源:addons.py

示例3: install_from_manifest

    def install_from_manifest(self, filepath):
        """
        Installs addons from a manifest
        :param filepath: path to the manifest of addons to install
        """
        manifest = ManifestParser()
        manifest.read(filepath)
        addons = manifest.get()

        for addon in addons:
            if "://" in addon["path"] or os.path.exists(addon["path"]):
                self.install_from_path(addon["path"])
                continue

            # No path specified, try to grab it off AMO
            locale = addon.get("amo_locale", "en_US")
            query = "https://services.addons.mozilla.org/" + locale + "/firefox/api/" + AMO_API_VERSION + "/"
            if "amo_id" in addon:
                query += "addon/" + addon["amo_id"]  # this query grabs information on the addon base on its id
            else:
                query += (
                    "search/" + addon["name"] + "/default/1"
                )  # this query grabs information on the first addon returned from a search
            install_path = AddonManager.get_amo_install_path(query)
            self.install_from_path(install_path)

        self.installed_manifests.append(filepath)
开发者ID:c0mmandCS,项目名称:Waterfox,代码行数:27,代码来源:addons.py

示例4: test_recursion_symlinks

    def test_recursion_symlinks(self):
        workspace = tempfile.mkdtemp()
        self.addCleanup(shutil.rmtree, workspace)

        # create two dirs
        os.makedirs(os.path.join(workspace, 'dir1'))
        os.makedirs(os.path.join(workspace, 'dir2'))

        # create cyclical symlinks
        os.symlink(os.path.join('..', 'dir1'),
                   os.path.join(workspace, 'dir2', 'ldir1'))
        os.symlink(os.path.join('..', 'dir2'),
                   os.path.join(workspace, 'dir1', 'ldir2'))

        # create one file in each dir
        open(os.path.join(workspace, 'dir1', 'f1.txt'), 'a').close()
        open(os.path.join(workspace, 'dir1', 'ldir2', 'f2.txt'), 'a').close()

        data = []

        def callback(rootdirectory, directory, subdirs, files):
            for f in files:
                data.append(f)

        ManifestParser._walk_directories([workspace], callback)
        self.assertEqual(sorted(data), ['f1.txt', 'f2.txt'])
开发者ID:luke-chang,项目名称:gecko-1,代码行数:26,代码来源:test_convert_symlinks.py

示例5: create_gallery_generator

def create_gallery_generator(command_line_arguments, css_directory):
  """
  Given command line arguments, wire up the application and return
  it to the main function. This requires creating most of the objects
  described in the other files from this directory.

  Args:
    command_line_arguments the command line arguments with the program
                           name removed.
    css_directory the directory containing the CSS files.
  """
  input_data = parse_command_line_arguments(command_line_arguments)
  # First parse the manifest file
  with open(input_data['manifest_file'], 'r') as manifest_file:
    parser = ManifestParser(manifest_file)
    lookup_table = parser.get_json_data()
  factory = GalleryItemFactory(lookup_table, input_data['should_prompt'])
  template_exporter = exporter.create_photo_directory_exporter()
  template_writer = \
      templatewriter.create_template_writer(input_data['output_directory'])
  return GalleryGenerator(gallery_item_factory=factory,
      input_directory=input_data['input_directory'],
      output_directory=input_data['output_directory'],
      static_files_directory=css_directory,
      exporter=template_exporter,
      template_writer=template_writer)
开发者ID:rahulraj,项目名称:web_projects,代码行数:26,代码来源:gallerygenerator.py

示例6: test_just_defaults

    def test_just_defaults(self):
        """Ensure a manifest with just a DEFAULT section exposes that data."""

        parser = ManifestParser()
        manifest = os.path.join(here, 'just-defaults.ini')
        parser.read(manifest)
        self.assertEqual(len(parser.tests), 0)
        self.assertTrue(manifest in parser.manifest_defaults)
        self.assertEquals(parser.manifest_defaults[manifest]['foo'], 'bar')
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:9,代码来源:test_manifestparser.py

示例7: test_parent_defaults_include

    def test_parent_defaults_include(self):
        parent_example = os.path.join(here, "parent", "include", "manifest.ini")
        parser = ManifestParser(manifests=(parent_example,))

        # global defaults should inherit all includes
        self.assertEqual(parser.get("name", top="data"), ["testFirst.js", "testSecond.js"])

        # include specific defaults should only inherit the actual include
        self.assertEqual(parser.get("name", disabled="YES"), ["testFirst.js"])
        self.assertEqual(parser.get("name", disabled="NO"), ["testSecond.js"])
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:10,代码来源:test_manifestparser.py

示例8: test_sanity

    def test_sanity(self):
        """Ensure basic parser is sane"""

        parser = ManifestParser()
        mozmill_example = os.path.join(here, "mozmill-example.ini")
        parser.read(mozmill_example)
        tests = parser.tests
        self.assertEqual(len(tests), len(file(mozmill_example).read().strip().splitlines()))

        # Ensure that capitalization and order aren't an issue:
        lines = ["[%s]" % test["name"] for test in tests]
        self.assertEqual(lines, file(mozmill_example).read().strip().splitlines())

        # Show how you select subsets of tests:
        mozmill_restart_example = os.path.join(here, "mozmill-restart-example.ini")
        parser.read(mozmill_restart_example)
        restart_tests = parser.get(type="restart")
        self.assertTrue(len(restart_tests) < len(parser.tests))
        self.assertEqual(len(restart_tests), len(parser.get(manifest=mozmill_restart_example)))
        self.assertFalse(
            [test for test in restart_tests if test["manifest"] != os.path.join(here, "mozmill-restart-example.ini")]
        )
        self.assertEqual(
            parser.get("name", tags=["foo"]),
            [
                "restartTests/testExtensionInstallUninstall/test2.js",
                "restartTests/testExtensionInstallUninstall/test1.js",
            ],
        )
        self.assertEqual(parser.get("name", foo="bar"), ["restartTests/testExtensionInstallUninstall/test2.js"])
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:30,代码来源:test_manifestparser.py

示例9: test_sanity

    def test_sanity(self):
        """Ensure basic parser is sane"""

        parser = ManifestParser()
        mozmill_example = os.path.join(here, 'mozmill-example.ini')
        parser.read(mozmill_example)
        tests = parser.tests
        self.assertEqual(len(tests), len(file(mozmill_example).read().strip().splitlines()))

        # Ensure that capitalization and order aren't an issue:
        lines = ['[%s]' % test['name'] for test in tests]
        self.assertEqual(lines, file(mozmill_example).read().strip().splitlines())

        # Show how you select subsets of tests:
        mozmill_restart_example = os.path.join(here, 'mozmill-restart-example.ini')
        parser.read(mozmill_restart_example)
        restart_tests = parser.get(type='restart')
        self.assertTrue(len(restart_tests) < len(parser.tests))
        self.assertEqual(len(restart_tests), len(parser.get(manifest=mozmill_restart_example)))
        self.assertFalse([test for test in restart_tests
                          if test['manifest'] != os.path.join(here, 'mozmill-restart-example.ini')])
        self.assertEqual(parser.get('name', tags=['foo']),
                         ['restartTests/testExtensionInstallUninstall/test2.js',
                          'restartTests/testExtensionInstallUninstall/test1.js'])
        self.assertEqual(parser.get('name', foo='bar'),
                         ['restartTests/testExtensionInstallUninstall/test2.js'])
开发者ID:AutomatedTester,项目名称:mozbase,代码行数:26,代码来源:test_manifestparser.py

示例10: test_manifest_list

    def test_manifest_list(self):
        """
        Ensure a manifest with just a DEFAULT section still returns
        itself from the manifests() method.
        """

        parser = ManifestParser()
        manifest = os.path.join(here, 'no-tests.ini')
        parser.read(manifest)
        self.assertEqual(len(parser.tests), 0)
        self.assertTrue(len(parser.manifests()) == 1)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:11,代码来源:test_manifestparser.py

示例11: test_parent_defaults_include

    def test_parent_defaults_include(self):
        parent_example = os.path.join(here, 'parent', 'include', 'manifest.ini')
        parser = ManifestParser(manifests=(parent_example,))

        # global defaults should inherit all includes
        self.assertEqual(parser.get('name', top='data'),
                         ['testFirst.js', 'testSecond.js'])

        # include specific defaults should only inherit the actual include
        self.assertEqual(parser.get('name', disabled='YES'),
                         ['testFirst.js'])
        self.assertEqual(parser.get('name', disabled='NO'),
                         ['testSecond.js'])
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:13,代码来源:test_manifestparser.py

示例12: test_manifest_ignore

    def test_manifest_ignore(self):
        """test manifest `ignore` parameter for ignoring directories"""

        stub = self.create_stub()
        try:
            ManifestParser.populate_directory_manifests([stub], filename="manifest.ini", ignore=("subdir",))
            parser = ManifestParser()
            parser.read(os.path.join(stub, "manifest.ini"))
            self.assertEqual([i["name"] for i in parser.tests], ["bar", "fleem", "foo"])
            self.assertFalse(os.path.exists(os.path.join(stub, "subdir", "manifest.ini")))
        except:
            raise
        finally:
            shutil.rmtree(stub)
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:14,代码来源:test_convert_directory.py

示例13: test_manifest_ignore

    def test_manifest_ignore(self):
        """test manifest `ignore` parameter for ignoring directories"""

        stub = self.create_stub()
        try:
            ManifestParser.populate_directory_manifests([stub], filename='manifest.ini', ignore=('subdir',))
            parser = ManifestParser()
            parser.read(os.path.join(stub, 'manifest.ini'))
            self.assertEqual([i['name'] for i in parser.tests],
                             ['bar', 'fleem', 'foo'])
            self.assertFalse(os.path.exists(os.path.join(stub, 'subdir', 'manifest.ini')))
        except:
            raise
        finally:
            shutil.rmtree(stub)
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:15,代码来源:test_convert_directory.py

示例14: test_install_from_manifest

    def test_install_from_manifest(self):

        temp_manifest = addon_stubs.generate_manifest()
        m = ManifestParser()
        m.read(temp_manifest)
        addons = m.get()
        # Obtain details of addons to install from the manifest
        addons_to_install = [self.am.addon_details(x['path'])['id'] for x in addons]

        self.am.install_from_manifest(temp_manifest)
        # Generate a list of addons installed in the profile
        addons_installed = [unicode(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
                            self.profile.profile, 'extensions', 'staged'))]
        self.assertEqual(addons_installed.sort(), addons_to_install.sort())
        # Cleanup the temporary addon and manifest directories
        mozfile.rmtree(os.path.dirname(temp_manifest))
开发者ID:markrcote,项目名称:mozbase,代码行数:16,代码来源:test_addons.py

示例15: test_server_root

    def test_server_root(self):
        """
        Test server_root properly expands as an absolute path
        """
        server_example = os.path.join(here, "parent", "level_1", "level_2", "level_3", "level_3_server-root.ini")
        parser = ManifestParser(manifests=(server_example,))

        # A regular variable will inherit its value directly
        self.assertEqual(parser.get("name", **{"other-root": "../root"}), ["test_3"])

        # server-root will expand its value as an absolute path
        # we will not find anything for the original value
        self.assertEqual(parser.get("name", **{"server-root": "../root"}), [])

        # check that the path has expanded
        self.assertEqual(parser.get("server-root")[0], os.path.join(here, "parent", "root"))
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:16,代码来源:test_manifestparser.py


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