OLD | NEW |
1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 def sha1(self, path): | 231 def sha1(self, path): |
232 contents = self.read_binary_file(path) | 232 contents = self.read_binary_file(path) |
233 return hashlib.sha1(contents).hexdigest() | 233 return hashlib.sha1(contents).hexdigest() |
234 | 234 |
235 def relpath(self, path, start='.'): | 235 def relpath(self, path, start='.'): |
236 return os.path.relpath(path, start) | 236 return os.path.relpath(path, start) |
237 | 237 |
238 class _WindowsError(exceptions.OSError): | 238 class _WindowsError(exceptions.OSError): |
239 """Fake exception for Linux and Mac.""" | 239 """Fake exception for Linux and Mac.""" |
240 pass | |
241 | 240 |
242 def remove(self, path, osremove=os.remove): | 241 def remove(self, path, osremove=os.remove): |
243 """On Windows, if a process was recently killed and it held on to a | 242 """On Windows, if a process was recently killed and it held on to a |
244 file, the OS will hold on to the file for a short while. This makes | 243 file, the OS will hold on to the file for a short while. This makes |
245 attempts to delete the file fail. To work around that, this method | 244 attempts to delete the file fail. To work around that, this method |
246 will retry for a few seconds until Windows is done with the file.""" | 245 will retry for a few seconds until Windows is done with the file.""" |
247 try: | 246 try: |
248 exceptions.WindowsError | 247 exceptions.WindowsError |
249 except AttributeError: | 248 except AttributeError: |
250 exceptions.WindowsError = FileSystem._WindowsError | 249 exceptions.WindowsError = FileSystem._WindowsError |
(...skipping 20 matching lines...) Expand all Loading... |
271 def split(self, path): | 270 def split(self, path): |
272 """Return (dirname, basename + '.' + ext)""" | 271 """Return (dirname, basename + '.' + ext)""" |
273 return os.path.split(path) | 272 return os.path.split(path) |
274 | 273 |
275 def splitext(self, path): | 274 def splitext(self, path): |
276 """Return (dirname + os.sep + basename, '.' + ext)""" | 275 """Return (dirname + os.sep + basename, '.' + ext)""" |
277 return os.path.splitext(path) | 276 return os.path.splitext(path) |
278 | 277 |
279 def make_executable(self, file_path): | 278 def make_executable(self, file_path): |
280 os.chmod(file_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_
IRGRP | stat.S_IXGRP) | 279 os.chmod(file_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_
IRGRP | stat.S_IXGRP) |
OLD | NEW |