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

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

Issue 14759009: Docserver: fix SubversionFileSystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: posixpath Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/subversion_file_system_test.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) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 from file_system import FileSystem, FileNotFoundError, StatInfo, ToUnicode 5 from file_system import FileSystem, FileNotFoundError, StatInfo, ToUnicode
6 from future import Future 6 from future import Future
7 import logging 7 import logging
8 import re 8 import re
9 import posixpath
9 import xml.dom.minidom as xml 10 import xml.dom.minidom as xml
10 from xml.parsers.expat import ExpatError 11 from xml.parsers.expat import ExpatError
11 12
12 class _AsyncFetchFuture(object): 13 class _AsyncFetchFuture(object):
13 def __init__(self, paths, fetcher, binary): 14 def __init__(self, paths, fetcher, binary):
14 # A list of tuples of the form (path, Future). 15 # A list of tuples of the form (path, Future).
15 self._fetches = [(path, fetcher.FetchAsync(path)) for path in paths] 16 self._fetches = [(path, fetcher.FetchAsync(path)) for path in paths]
16 self._value = {} 17 self._value = {}
17 self._error = None 18 self._error = None
18 self._binary = binary 19 self._binary = binary
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 # All versions in StatInfo need to be strings. 112 # All versions in StatInfo need to be strings.
112 return StatInfo(str(parent_version), 113 return StatInfo(str(parent_version),
113 dict((path, str(version)) 114 dict((path, str(version))
114 for path, version in child_versions.iteritems())) 115 for path, version in child_versions.iteritems()))
115 116
116 # Bleh, but, this data is so unreliable. There are actually some empty file 117 # Bleh, but, this data is so unreliable. There are actually some empty file
117 # listings caused by git/svn/something not cleaning up empty dirs. 118 # listings caused by git/svn/something not cleaning up empty dirs.
118 return StatInfo('0', {}) 119 return StatInfo('0', {})
119 120
120 def Stat(self, path): 121 def Stat(self, path):
121 directory = path.rsplit('/', 1)[0] 122 directory, filename = posixpath.split(path)
122 result = self._stat_fetcher.Fetch(directory + '/') 123 result = self._stat_fetcher.Fetch(directory + '/')
123 if result.status_code == 404: 124 if result.status_code == 404:
124 raise FileNotFoundError( 125 raise FileNotFoundError(
125 'Got 404 when fetching %s from %s for Stat' % (path, directory)) 126 'Got 404 when fetching %s from %s for Stat' % (path, directory))
126 stat_info = self._CreateStatInfo(result.content) 127 stat_info = self._CreateStatInfo(result.content)
127 if not path.endswith('/'): 128 if path.endswith('/'):
128 filename = path.rsplit('/', 1)[-1] 129 return stat_info
129 if filename not in stat_info.child_versions: 130 if filename not in stat_info.child_versions:
130 raise FileNotFoundError('%s was not in child versions' % filename) 131 raise FileNotFoundError('%s was not in child versions' % filename)
131 stat_info.version = stat_info.child_versions[filename] 132 return StatInfo(stat_info.child_versions[filename])
132 return stat_info
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/subversion_file_system_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698