Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from file_system import FileSystem | |
| 6 from future import Future | |
| 7 import logging | |
| 8 | |
| 9 class _AsyncFetchFuture(object): | |
| 10 def __init__(self, paths, binary, patched_files, svn_file_system, | |
| 11 patch_file_system): | |
| 12 patched_paths = [] | |
| 13 unpatched_paths = [] | |
| 14 for path in paths: | |
| 15 if path in patched_files: | |
| 16 patched_paths.append(path) | |
| 17 else: | |
| 18 unpatched_paths.append(path) | |
|
not at google - send to devlin
2013/04/26 23:53:53
you may want to use set()s everywhere for these pa
方觉(Fang Jue)
2013/04/27 01:02:48
Done. Python is awesome!
| |
| 19 logging.info(patched_paths) | |
| 20 logging.info(unpatched_paths) | |
| 21 self._svn_future = svn_file_system.Read(unpatched_paths, binary) | |
| 22 self._patched_future = patch_file_system.Read(patched_paths, binary) | |
|
not at google - send to devlin
2013/04/26 23:53:53
Just pass these futures directly in through the co
方觉(Fang Jue)
2013/04/27 01:02:48
Done.
| |
| 23 | |
| 24 def Get(self): | |
| 25 value = self._svn_future.Get() | |
| 26 value.update(self._patched_future.Get()) | |
| 27 return value | |
| 28 | |
| 29 class PatchedFileSystem(FileSystem): | |
| 30 """ Class to fetch resources with a patch applied. | |
| 31 """ | |
| 32 def __init__(self, patched_files, svn_file_system, patch_file_system): | |
| 33 self._patched_files = patched_files | |
| 34 self._svn_file_system = svn_file_system | |
| 35 self._patch_file_system = patch_file_system | |
| 36 | |
| 37 def Read(self, paths, binary=False): | |
| 38 return Future(delegate=_AsyncFetchFuture( | |
| 39 paths, | |
| 40 binary, | |
| 41 self._patched_files, | |
| 42 self._svn_file_system, | |
| 43 self._patch_file_system)) | |
| 44 | |
| 45 # We assume that a patchset, once created, will never change. | |
| 46 def Stat(self, path): | |
| 47 return self._svn_file_system.Stat(path) | |
| OLD | NEW |