OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/env python2.5 |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import errno | 6 import errno |
7 import os | 7 import os |
8 import re | 8 import re |
9 import StringIO | 9 import StringIO |
10 | 10 |
11 def _RaiseNotFound(path): | 11 def _RaiseNotFound(path): |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 return re.sub(re.escape(os.path.sep), self.sep, os.path.join(*comps)) | 66 return re.sub(re.escape(os.path.sep), self.sep, os.path.join(*comps)) |
67 | 67 |
68 def open_for_reading(self, path): | 68 def open_for_reading(self, path): |
69 return StringIO.StringIO(self.read_binary_file(path)) | 69 return StringIO.StringIO(self.read_binary_file(path)) |
70 | 70 |
71 def read_binary_file(self, path): | 71 def read_binary_file(self, path): |
72 # Intentionally raises KeyError if we don't recognize the path. | 72 # Intentionally raises KeyError if we don't recognize the path. |
73 if self.files[path] is None: | 73 if self.files[path] is None: |
74 _RaiseNotFound(path) | 74 _RaiseNotFound(path) |
75 return self.files[path] | 75 return self.files[path] |
OLD | NEW |