OLD | NEW |
---|---|
1 # Copyright 2015 The LUCI Authors. All rights reserved. | 1 # Copyright 2015 The LUCI Authors. All rights reserved. |
2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
4 | 4 |
5 """Wraps os, os.path and shutil functions to work around MAX_PATH on Windows.""" | 5 """Wraps os, os.path and shutil functions to work around MAX_PATH on Windows.""" |
6 | 6 |
7 import __builtin__ | 7 import __builtin__ |
8 import inspect | 8 import inspect |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 | 114 |
115 else: | 115 else: |
116 | 116 |
117 | 117 |
118 def extend(path): | 118 def extend(path): |
119 """Convert the path back to utf-8. | 119 """Convert the path back to utf-8. |
120 | 120 |
121 In some rare case, concatenating str and unicode may cause a | 121 In some rare case, concatenating str and unicode may cause a |
122 UnicodeEncodeError because the default encoding is 'ascii'. | 122 UnicodeEncodeError because the default encoding is 'ascii'. |
123 """ | 123 """ |
124 assert os.path.isabs(path), path | 124 assert os.path.isabs(path), '%s must be absolute' % path |
M-A Ruel
2017/05/08 13:13:14
update lines 37-38 to be coherent
Use %r
what do y
kjlubick
2017/05/08 18:59:29
Done.
I don't know what I meant.
To quote Gary
| |
125 assert isinstance(path, unicode), path | 125 assert isinstance(path, unicode), '%s must be a path or unicode' % path |
126 return path.encode('utf-8') | 126 return path.encode('utf-8') |
127 | 127 |
128 | 128 |
129 def trim(path): | 129 def trim(path): |
130 """Path mangling is not needed on POSIX.""" | 130 """Path mangling is not needed on POSIX.""" |
131 assert os.path.isabs(path), path | 131 assert os.path.isabs(path), path |
132 assert isinstance(path, str), path | 132 assert isinstance(path, str), path |
133 return path.decode('utf-8') | 133 return path.decode('utf-8') |
134 | 134 |
135 | 135 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 for _fn in _os_fns: | 205 for _fn in _os_fns: |
206 if hasattr(os, _fn): | 206 if hasattr(os, _fn): |
207 sys.modules[__name__].__dict__.setdefault( | 207 sys.modules[__name__].__dict__.setdefault( |
208 _fn, _get_lambda(getattr(os, _fn))) | 208 _fn, _get_lambda(getattr(os, _fn))) |
209 | 209 |
210 | 210 |
211 for _fn in _os_path_fns: | 211 for _fn in _os_path_fns: |
212 if hasattr(os.path, _fn): | 212 if hasattr(os.path, _fn): |
213 sys.modules[__name__].__dict__.setdefault( | 213 sys.modules[__name__].__dict__.setdefault( |
214 _fn, _get_lambda(getattr(os.path, _fn))) | 214 _fn, _get_lambda(getattr(os.path, _fn))) |
OLD | NEW |