| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import errno | 5 import errno |
| 6 import fnmatch | 6 import fnmatch |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import StringIO | 9 import StringIO |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 def open_for_reading(self, path): | 80 def open_for_reading(self, path): |
| 81 return StringIO.StringIO(self.read_binary_file(path)) | 81 return StringIO.StringIO(self.read_binary_file(path)) |
| 82 | 82 |
| 83 def read_binary_file(self, path): | 83 def read_binary_file(self, path): |
| 84 # Intentionally raises KeyError if we don't recognize the path. | 84 # Intentionally raises KeyError if we don't recognize the path. |
| 85 if self.files[path] is None: | 85 if self.files[path] is None: |
| 86 _RaiseNotFound(path) | 86 _RaiseNotFound(path) |
| 87 return self.files[path] | 87 return self.files[path] |
| 88 | 88 |
| 89 @staticmethod | 89 def relpath(self, path, base): |
| 90 def relpath(path, base): | |
| 91 # This implementation is wrong in many ways; assert to check them for now. | 90 # This implementation is wrong in many ways; assert to check them for now. |
| 91 if not base.endswith(self.sep): |
| 92 base += self.sep |
| 92 assert path.startswith(base) | 93 assert path.startswith(base) |
| 93 assert base.endswith('/') | |
| 94 return path[len(base):] | 94 return path[len(base):] |
| OLD | NEW |