OLD | NEW |
1 # Copyright (C) 2009 Google Inc. All rights reserved. | 1 # Copyright (C) 2009 Google Inc. All rights reserved. |
2 # Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com) | 2 # Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com) |
3 # Copyright (C) 2010 ProFUSION embedded systems | 3 # Copyright (C) 2010 ProFUSION embedded systems |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 except IOError as err: | 125 except IOError as err: |
126 message = ("Could not read file. Skipping: '%s'\n %s" % (file_path,
err)) | 126 message = ("Could not read file. Skipping: '%s'\n %s" % (file_path,
err)) |
127 _log.warn(message) | 127 _log.warn(message) |
128 return | 128 return |
129 | 129 |
130 self._processor.process(lines, file_path, **kwargs) | 130 self._processor.process(lines, file_path, **kwargs) |
131 | 131 |
132 def _process_directory(self, directory): | 132 def _process_directory(self, directory): |
133 """Process all files in the given directory, recursively.""" | 133 """Process all files in the given directory, recursively.""" |
134 # FIXME: We should consider moving to self.filesystem.files_under() (or
adding walk() to FileSystem) | 134 # FIXME: We should consider moving to self.filesystem.files_under() (or
adding walk() to FileSystem) |
135 for dir_path, dir_names, file_names in os.walk(directory): | 135 for dir_path, _, file_names in os.walk(directory): |
136 for file_name in file_names: | 136 for file_name in file_names: |
137 file_path = self.filesystem.join(dir_path, file_name) | 137 file_path = self.filesystem.join(dir_path, file_name) |
138 self.process_file(file_path) | 138 self.process_file(file_path) |
139 | 139 |
140 def process_paths(self, paths): | 140 def process_paths(self, paths): |
141 for path in paths: | 141 for path in paths: |
142 if self.filesystem.isdir(path): | 142 if self.filesystem.isdir(path): |
143 self._process_directory(directory=path) | 143 self._process_directory(directory=path) |
144 else: | 144 else: |
145 self.process_file(path) | 145 self.process_file(path) |
146 | 146 |
147 def count_delete_only_file(self): | 147 def count_delete_only_file(self): |
148 """Count up files that contains only deleted lines. | 148 """Count up files that contains only deleted lines. |
149 | 149 |
150 Files which has no modified or newly-added lines don't need | 150 Files which has no modified or newly-added lines don't need |
151 to check style, but should be treated as checked. For that | 151 to check style, but should be treated as checked. For that |
152 purpose, we just count up the number of such files. | 152 purpose, we just count up the number of such files. |
153 """ | 153 """ |
154 self.delete_only_file_count += 1 | 154 self.delete_only_file_count += 1 |
OLD | NEW |