| Index: tools/grit/grit/util.py
|
| diff --git a/tools/grit/grit/util.py b/tools/grit/grit/util.py
|
| index 93dce2610074cdef7fbc0190e3e36d3950d1d94f..c013a69c54a4a1a4e02c3158415a5618e207188c 100755
|
| --- a/tools/grit/grit/util.py
|
| +++ b/tools/grit/grit/util.py
|
| @@ -21,6 +21,8 @@ from grit import lazy_re
|
|
|
| _root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
|
| +_replacement_paths = {}
|
| +
|
|
|
| # Unique constants for use by ReadFile().
|
| BINARY, RAW_TEXT = range(2)
|
| @@ -203,8 +205,10 @@ def ReadFile(filename, encoding):
|
| the file in binary mode, or RAW_TEXT to read it with newline
|
| conversion but without decoding to Unicode.
|
| '''
|
| + path = os.path.abspath(filename)
|
| + replacement_path = _replacement_paths.get(path, path)
|
| mode = 'rb' if encoding == BINARY else 'rU'
|
| - with open(filename, mode) as f:
|
| + with open(replacement_path, mode) as f:
|
| data = f.read()
|
| if encoding not in (BINARY, RAW_TEXT):
|
| data = data.decode(encoding)
|
| @@ -660,3 +664,7 @@ class TempDir(object):
|
| os.chdir(self.path)
|
| def __exit__(self, *exc_info):
|
| os.chdir(self.oldpath)
|
| +
|
| +def SetReplacementPaths(replacement_paths):
|
| + global _replacement_paths
|
| + _replacement_paths = replacement_paths
|
|
|