Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: Tools/Scripts/webkitpy/common/system/filesystem_mock.py

Issue 493413002: Fix runtime error in copytree() MockFileSystem (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressing comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Tools/Scripts/webkitpy/common/system/filesystem_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2009 Google Inc. All rights reserved. 1 # Copyright (C) 2009 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 # cases like path='/foo/b' and f='/foo/bar/baz'. 384 # cases like path='/foo/b' and f='/foo/bar/baz'.
385 if f == path or f.startswith(path + self.sep): 385 if f == path or f.startswith(path + self.sep):
386 self.files[f] = None 386 self.files[f] = None
387 387
388 self.dirs = set(filter(lambda d: not (d == path or d.startswith(path + s elf.sep)), self.dirs)) 388 self.dirs = set(filter(lambda d: not (d == path or d.startswith(path + s elf.sep)), self.dirs))
389 389
390 def copytree(self, source, destination): 390 def copytree(self, source, destination):
391 source = self.normpath(source) 391 source = self.normpath(source)
392 destination = self.normpath(destination) 392 destination = self.normpath(destination)
393 393
394 for source_file in self.files: 394 for source_file in list(self.files):
395 if source_file.startswith(source): 395 if source_file.startswith(source):
396 destination_path = self.join(destination, self.relpath(source_fi le, source)) 396 destination_path = self.join(destination, self.relpath(source_fi le, source))
397 self.maybe_make_directory(self.dirname(destination_path)) 397 self.maybe_make_directory(self.dirname(destination_path))
398 self.files[destination_path] = self.files[source_file] 398 self.files[destination_path] = self.files[source_file]
399 399
400 def split(self, path): 400 def split(self, path):
401 idx = path.rfind(self.sep) 401 idx = path.rfind(self.sep)
402 if idx == -1: 402 if idx == -1:
403 return ('', path) 403 return ('', path)
404 return (path[:idx], path[(idx + 1):]) 404 return (path[:idx], path[(idx + 1):])
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 return self.data.readline(length) 476 return self.data.readline(length)
477 477
478 def __iter__(self): 478 def __iter__(self):
479 return self.data.__iter__() 479 return self.data.__iter__()
480 480
481 def next(self): 481 def next(self):
482 return self.data.next() 482 return self.data.next()
483 483
484 def seek(self, offset, whence=os.SEEK_SET): 484 def seek(self, offset, whence=os.SEEK_SET):
485 self.data.seek(offset, whence) 485 self.data.seek(offset, whence)
OLDNEW
« no previous file with comments | « no previous file | Tools/Scripts/webkitpy/common/system/filesystem_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698