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


Python filesystem.FileSystem类代码示例

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


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

示例1: load_test_repositories

 def load_test_repositories():
     filesystem = FileSystem()
     webkit_finder = WebKitFinder(filesystem)
     test_repositories_path = webkit_finder.path_from_webkit_base(
         "LayoutTests", "imported", "w3c", "resources", "TestRepositories"
     )
     return json.loads(filesystem.read_text_file(test_repositories_path))
开发者ID:rhythmkay,项目名称:webkit,代码行数:7,代码来源:test_downloader.py

示例2: load_json

 def load_json(self):
     filesystem = FileSystem()
     json_path = filesystem.join(filesystem.dirname(filesystem.path_to_module('webkitpy.common.config')), 'contributors.json')
     try:
         contributors = json.loads(filesystem.read_text_file(json_path))
     except ValueError, e:
         sys.exit('contributors.json is malformed: ' + str(e))
开发者ID:eocanha,项目名称:webkit,代码行数:7,代码来源:committers.py

示例3: load_json

    def load_json():
        filesystem = FileSystem()
        json_path = filesystem.join(filesystem.dirname(filesystem.path_to_module('webkitpy.common.config')), 'contributors.json')
        contributors = json.loads(filesystem.read_text_file(json_path))

        return {
            'Contributors': [Contributor(name, data.get('emails'), data.get('nicks')) for name, data in contributors['Contributors'].iteritems()],
            'Committers': [Committer(name, data.get('emails'), data.get('nicks')) for name, data in contributors['Committers'].iteritems()],
            'Reviewers': [Reviewer(name, data.get('emails'), data.get('nicks')) for name, data in contributors['Reviewers'].iteritems()],
        }
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:10,代码来源:committers.py

示例4: test_import_web_platform_test_modules

    def test_import_web_platform_test_modules(self):
        fs = FileSystem()
        current_dir, name = fs.split(fs.realpath(__file__))
        doc_root_dir = fs.join(current_dir, "..", "..", "..", "..", "..", "LayoutTests", "imported", "w3c", "web-platform-tests")
        tools_dir = fs.join(doc_root_dir, "tools")

        sys.path.insert(0, doc_root_dir)
        try:
            file, pathname, description = imp.find_module("tools")
        except ImportError, e:
            self.fail(e)
开发者ID:cheekiatng,项目名称:webkit,代码行数:11,代码来源:web_platform_test_server_unittest.py

示例5: integration_test_coverage_works

 def integration_test_coverage_works(self):
     filesystem = FileSystem()
     executive = Executive()
     module_path = filesystem.path_to_module(self.__module__)
     script_dir = module_path[0:module_path.find('webkitpy') - 1]
     proc = executive.popen([sys.executable, filesystem.join(script_dir, 'test-webkitpy'), '-c', STUBS_CLASS + '.test_empty'],
                            stdout=executive.PIPE, stderr=executive.PIPE)
     out, _ = proc.communicate()
     retcode = proc.returncode
     self.assertEqual(retcode, 0)
     self.assertIn('Cover', out)
开发者ID:Igalia,项目名称:blink,代码行数:11,代码来源:main_unittest.py

示例6: test_remove_file_with_retry

    def test_remove_file_with_retry(self):
        RealFileSystemTest._remove_failures = 2

        def remove_with_exception(filename):
            RealFileSystemTest._remove_failures -= 1
            if RealFileSystemTest._remove_failures >= 0:
                try:
                    raise WindowsError
                except NameError:
                    raise FileSystem._WindowsError

        fs = FileSystem()
        self.assertTrue(fs.remove('filename', remove_with_exception))
        self.assertEqual(-1, RealFileSystemTest._remove_failures)
开发者ID:hinike,项目名称:opera,代码行数:14,代码来源:filesystem_unittest.py

示例7: setUp

 def setUp(self):
     LoggingTestCase.setUp(self)
     # FIXME: This should be a MockFileSystem once TextFileReader is moved entirely on top of FileSystem.
     self.filesystem = FileSystem()
     self._temp_dir = str(self.filesystem.mkdtemp())
     self._processor = TextFileReaderTest.MockProcessor()
     self._file_reader = TextFileReader(self.filesystem, self._processor)
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:7,代码来源:filereader_unittest.py

示例8: setUp

 def setUp(self):
     self._filesystem = FileSystem()
     self._temp_dir = str(self._filesystem.mkdtemp(suffix="exportfiles"))
     self._old_cwd = self._filesystem.getcwd()
     self._filesystem.chdir(self._temp_dir)
     self._filesystem.write_text_file(os.path.join(self._temp_dir, "sorted_file.exp.in"), _sorted_file_contents)
     self._filesystem.write_text_file(os.path.join(self._temp_dir, "non_sorted_file.exp.in"), _non_sorted_file_contents)
     self._filesystem.write_text_file(os.path.join(self._temp_dir, "parse_error_file.exp.in"), _parse_error_file_contents)
开发者ID:chenbk85,项目名称:webkit2-wincairo,代码行数:8,代码来源:exportfile_unittest.py

示例9: test_read_and_write_text_file

    def test_read_and_write_text_file(self):
        fs = FileSystem()
        text_path = None

        unicode_text_string = u'\u016An\u012Dc\u014Dde\u033D'
        try:
            text_path = tempfile.mktemp(prefix='tree_unittest_')
            file = fs.open_text_file_for_writing(text_path)
            file.write(unicode_text_string)
            file.close()

            file = fs.open_text_file_for_reading(text_path)
            read_text = file.read()
            file.close()

            self.assertEqual(read_text, unicode_text_string)
        finally:
            if text_path and fs.isfile(text_path):
                os.remove(text_path)
开发者ID:mirror,项目名称:chromium,代码行数:19,代码来源:filesystem_unittest.py

示例10: load_ews_classes

    def load_ews_classes(cls):
        filesystem = FileSystem()
        json_path = filesystem.join(filesystem.dirname(filesystem.path_to_module('webkitpy.common.config')), 'ews.json')
        try:
            ewses = json.loads(filesystem.read_text_file(json_path))
        except ValueError:
            return None

        classes = []
        for name, config in ewses.iteritems():
            classes.append(type(name.encode('utf-8').translate(None, ' -'), (AbstractEarlyWarningSystem,), {
                'name': config.get('name', config['port'] + '-ews'),
                'port_name': config['port'],
                'architecture': config.get('architecture', None),
                '_build_style': config.get('style', "release"),
                'watchers': config.get('watchers', []),
                'run_tests': config.get('runTests', cls.run_tests),
            }))
        return classes
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:19,代码来源:earlywarningsystem.py

示例11: test_maybe_make_directory__failure

    def test_maybe_make_directory__failure(self):
        # FIXME: os.chmod() doesn't work on Windows to set directories
        # as readonly, so we skip this test for now.
        if sys.platform in ('win32', 'cygwin'):
            return

        fs = FileSystem()
        with fs.mkdtemp(prefix='filesystem_unittest_') as d:
            # Remove write permissions on the parent directory.
            os.chmod(d, stat.S_IRUSR)

            # Now try to create a sub directory - should fail.
            sub_dir = fs.join(d, 'subdir')
            self.assertRaises(OSError, fs.maybe_make_directory, sub_dir)

            # Clean up in case the test failed and we did create the
            # directory.
            if os.path.exists(sub_dir):
                os.rmdir(sub_dir)
开发者ID:hinike,项目名称:opera,代码行数:19,代码来源:filesystem_unittest.py

示例12: test_chdir

 def test_chdir(self):
     fs = FileSystem()
     cwd = fs.getcwd()
     newdir = '/'
     if sys.platform == 'win32':
         newdir = 'c:\\'
     fs.chdir(newdir)
     self.assertEqual(fs.getcwd(), newdir)
     fs.chdir(cwd)
开发者ID:hinike,项目名称:opera,代码行数:9,代码来源:filesystem_unittest.py

示例13: test_maybe_make_directory__success

    def test_maybe_make_directory__success(self):
        fs = FileSystem()

        with fs.mkdtemp(prefix='filesystem_unittest_') as base_path:
            sub_path = os.path.join(base_path, "newdir")
            self.assertFalse(os.path.exists(sub_path))
            self.assertFalse(fs.isdir(sub_path))

            fs.maybe_make_directory(sub_path)
            self.assertTrue(os.path.exists(sub_path))
            self.assertTrue(fs.isdir(sub_path))

            # Make sure we can re-create it.
            fs.maybe_make_directory(sub_path)
            self.assertTrue(os.path.exists(sub_path))
            self.assertTrue(fs.isdir(sub_path))

            # Clean up.
            os.rmdir(sub_path)

        self.assertFalse(os.path.exists(base_path))
        self.assertFalse(fs.isdir(base_path))
开发者ID:hinike,项目名称:opera,代码行数:22,代码来源:filesystem_unittest.py

示例14: test_listdir

 def test_listdir(self):
     fs = FileSystem()
     with fs.mkdtemp(prefix='filesystem_unittest_') as d:
         self.assertEqual(fs.listdir(d), [])
         new_file = os.path.join(d, 'foo')
         fs.write_text_file(new_file, u'foo')
         self.assertEqual(fs.listdir(d), ['foo'])
         os.remove(new_file)
开发者ID:hinike,项目名称:opera,代码行数:8,代码来源:filesystem_unittest.py

示例15: setUp

    def setUp(self):
        # FIXME: This should not need to touch the filesystem, however
        # ChangeLog is difficult to mock at current.
        self.filesystem = FileSystem()
        self.temp_dir = str(self.filesystem.mkdtemp(suffix="changelogs"))
        self.old_cwd = self.filesystem.getcwd()
        self.filesystem.chdir(self.temp_dir)
        self.webkit_base = WebKitFinder(self.filesystem).webkit_base()

        # Trick commit-log-editor into thinking we're in a Subversion working copy so it won't
        # complain about not being able to figure out what SCM is in use.
        # FIXME: VCSTools.pm is no longer so easily fooled.  It logs because "svn info" doesn't
        # treat a bare .svn directory being part of an svn checkout.
        self.filesystem.maybe_make_directory(".svn")
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:14,代码来源:checkout_unittest.py


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