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

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

Issue 491653002: Docserver: Use GitilesFileSystem instead of SubversionFileSystem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 class HostFileSystemIterator(object): 6 class HostFileSystemIterator(object):
7 '''Provides methods for iterating through host file systems, in both 7 '''Provides methods for iterating through host file systems, in both
8 ascending (oldest to newest version) and descending order. 8 ascending (oldest to newest version) and descending order.
9 ''' 9 '''
10 10
11 def __init__(self, file_system_provider, branch_utility): 11 def __init__(self, file_system_provider, branch_utility):
12 self._file_system_provider = file_system_provider 12 self._file_system_provider = file_system_provider
13 self._branch_utility = branch_utility 13 self._branch_utility = branch_utility
14 14
15 def _ForEach(self, channel_info, callback, get_next): 15 def _ForEach(self, channel_info, callback, get_next):
16 '''Iterates through a sequence of file systems defined by |get_next| until 16 '''Iterates through a sequence of file systems defined by |get_next| until
17 |callback| returns False, or until the end of the sequence of file systems 17 |callback| returns False, or until the end of the sequence of file systems
18 is reached. Returns the BranchUtility.ChannelInfo of the last file system 18 is reached. Returns the BranchUtility.ChannelInfo of the last file system
19 for which |callback| returned True. 19 for which |callback| returned True.
20 ''' 20 '''
21 last_true = None 21 last_true = None
22 while channel_info is not None: 22 while channel_info is not None:
23 if channel_info.branch == 'trunk': 23 if channel_info.branch == 'master':
24 file_system = self._file_system_provider.GetTrunk() 24 file_system = self._file_system_provider.GetMaster()
25 else: 25 else:
26 file_system = self._file_system_provider.GetBranch(channel_info.branch) 26 file_system = self._file_system_provider.GetBranch(channel_info.branch)
27 if not callback(file_system, channel_info): 27 if not callback(file_system, channel_info):
28 return last_true 28 return last_true
29 last_true = channel_info 29 last_true = channel_info
30 channel_info = get_next(channel_info) 30 channel_info = get_next(channel_info)
31 return last_true 31 return last_true
32 32
33 def Ascending(self, channel_info, callback): 33 def Ascending(self, channel_info, callback):
34 return self._ForEach(channel_info, callback, self._branch_utility.Newer) 34 return self._ForEach(channel_info, callback, self._branch_utility.Newer)
35 35
36 def Descending(self, channel_info, callback): 36 def Descending(self, channel_info, callback):
37 return self._ForEach(channel_info, callback, self._branch_utility.Older) 37 return self._ForEach(channel_info, callback, self._branch_utility.Older)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698