Title: [160085] trunk/Tools
- Revision
- 160085
- Author
- [email protected]
- Date
- 2013-12-04 03:19:56 -0800 (Wed, 04 Dec 2013)
Log Message
Remove codecs and os dependencies from filereader.py in webkitpy/style.
https://bugs.webkit.org/show_bug.cgi?id=124719
Although TextFileReader requires a FileSystem it circumvents it in two places!
We should use the FileSystem only and remove codecs and os imports.
Patch by László Langó <[email protected]> on 2013-12-04
Reviewed by Zoltan Herczeg.
* Scripts/webkitpy/common/system/filesystem.py:
(FileSystem.open_stdin): Moved from TextFileReader
* Scripts/webkitpy/style/filereader.py:
(TextFileReader._read_lines): use FileSystem instead of calling codecs.open directly
(TextFileReader._process_directory): use FileSystem instead of calling os.walk directly
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (160084 => 160085)
--- trunk/Tools/ChangeLog 2013-12-04 11:11:33 UTC (rev 160084)
+++ trunk/Tools/ChangeLog 2013-12-04 11:19:56 UTC (rev 160085)
@@ -1,5 +1,21 @@
2013-12-04 László Langó <[email protected]>
+ Remove codecs and os dependencies from filereader.py in webkitpy/style.
+ https://bugs.webkit.org/show_bug.cgi?id=124719
+
+ Although TextFileReader requires a FileSystem it circumvents it in two places!
+ We should use the FileSystem only and remove codecs and os imports.
+
+ Reviewed by Zoltan Herczeg.
+
+ * Scripts/webkitpy/common/system/filesystem.py:
+ (FileSystem.open_stdin): Moved from TextFileReader
+ * Scripts/webkitpy/style/filereader.py:
+ (TextFileReader._read_lines): use FileSystem instead of calling codecs.open directly
+ (TextFileReader._process_directory): use FileSystem instead of calling os.walk directly
+
+2013-12-04 László Langó <[email protected]>
+
check-webkit-style should check member initialization indentation.
https://bugs.webkit.org/show_bug.cgi?id=124820
Modified: trunk/Tools/Scripts/webkitpy/common/system/filesystem.py (160084 => 160085)
--- trunk/Tools/Scripts/webkitpy/common/system/filesystem.py 2013-12-04 11:11:33 UTC (rev 160084)
+++ trunk/Tools/Scripts/webkitpy/common/system/filesystem.py 2013-12-04 11:19:56 UTC (rev 160085)
@@ -206,6 +206,12 @@
def open_text_file_for_writing(self, path):
return codecs.open(path, 'w', 'utf8')
+ def open_stdin(self):
+ return codecs.StreamReaderWriter(sys.stdin,
+ codecs.getreader('utf8'),
+ codecs.getwriter('utf8'),
+ 'replace')
+
def read_text_file(self, path):
"""Return the contents of the file at the given path as a Unicode string.
Modified: trunk/Tools/Scripts/webkitpy/style/filereader.py (160084 => 160085)
--- trunk/Tools/Scripts/webkitpy/style/filereader.py 2013-12-04 11:11:33 UTC (rev 160084)
+++ trunk/Tools/Scripts/webkitpy/style/filereader.py 2013-12-04 11:19:56 UTC (rev 160085)
@@ -30,9 +30,7 @@
"""Supports reading and processing text files."""
-import codecs
import logging
-import os
import sys
@@ -76,17 +74,13 @@
"""
# Support the UNIX convention of using "-" for stdin.
if file_path == '-':
- file = codecs.StreamReaderWriter(sys.stdin,
- codecs.getreader('utf8'),
- codecs.getwriter('utf8'),
- 'replace')
+ file = self.filesystem.open_stdin()
else:
# We do not open the file with universal newline support
# (codecs does not support it anyway), so the resulting
# lines contain trailing "\r" characters if we are reading
# a file with CRLF endings.
- # FIXME: This should use self.filesystem
- file = codecs.open(file_path, 'r', 'utf8', 'replace')
+ file = self.filesystem.open_text_file_for_reading(file_path)
try:
contents = file.read()
@@ -131,11 +125,8 @@
def _process_directory(self, directory):
"""Process all files in the given directory, recursively."""
- # FIXME: We should consider moving to self.filesystem.files_under() (or adding walk() to FileSystem)
- for dir_path, dir_names, file_names in os.walk(directory):
- for file_name in file_names:
- file_path = self.filesystem.join(dir_path, file_name)
- self.process_file(file_path)
+ for file_path in self.filesystem.files_under(directory):
+ self.process_file(file_path)
def process_paths(self, paths):
for path in paths:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes