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

Side by Side Diff: chrome/common/extensions/docs/server2/patched_file_system.py

Issue 14125010: Docserver: Add support for viewing docs with a codereview patch applied (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 8 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698