OLD | NEW |
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 import re | 5 import re |
6 import xml.dom.minidom as xml | 6 import xml.dom.minidom as xml |
7 from xml.parsers.expat import ExpatError | 7 from xml.parsers.expat import ExpatError |
8 | 8 |
9 import file_system | 9 import file_system |
10 from future import Future | 10 from future import Future |
(...skipping 14 matching lines...) Expand all Loading... |
25 return files | 25 return files |
26 | 26 |
27 def Get(self): | 27 def Get(self): |
28 for path, future in self._fetches: | 28 for path, future in self._fetches: |
29 result = future.Get() | 29 result = future.Get() |
30 if result.status_code == 404: | 30 if result.status_code == 404: |
31 raise file_system.FileNotFoundError(path) | 31 raise file_system.FileNotFoundError(path) |
32 elif path.endswith('/'): | 32 elif path.endswith('/'): |
33 self._value[path] = self._ListDir(result.content) | 33 self._value[path] = self._ListDir(result.content) |
34 elif not self._binary: | 34 elif not self._binary: |
35 self._value[path] = file_system._ProcessFileData(result.content, path) | 35 self._value[path] = file_system._ToUnicode(result.content) |
36 else: | 36 else: |
37 self._value[path] = result.content | 37 self._value[path] = result.content |
38 if self._error is not None: | 38 if self._error is not None: |
39 raise self._error | 39 raise self._error |
40 return self._value | 40 return self._value |
41 | 41 |
42 class SubversionFileSystem(file_system.FileSystem): | 42 class SubversionFileSystem(file_system.FileSystem): |
43 """Class to fetch resources from src.chromium.org. | 43 """Class to fetch resources from src.chromium.org. |
44 """ | 44 """ |
45 def __init__(self, fetcher, stat_fetcher): | 45 def __init__(self, fetcher, stat_fetcher): |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 result = self._stat_fetcher.Fetch(directory + '/') | 95 result = self._stat_fetcher.Fetch(directory + '/') |
96 if result.status_code == 404: | 96 if result.status_code == 404: |
97 raise file_system.FileNotFoundError(path) | 97 raise file_system.FileNotFoundError(path) |
98 stat_info = self._CreateStatInfo(result.content) | 98 stat_info = self._CreateStatInfo(result.content) |
99 if not path.endswith('/'): | 99 if not path.endswith('/'): |
100 filename = path.rsplit('/', 1)[-1] | 100 filename = path.rsplit('/', 1)[-1] |
101 if filename not in stat_info.child_versions: | 101 if filename not in stat_info.child_versions: |
102 raise file_system.FileNotFoundError(path) | 102 raise file_system.FileNotFoundError(path) |
103 stat_info.version = stat_info.child_versions[filename] | 103 stat_info.version = stat_info.child_versions[filename] |
104 return stat_info | 104 return stat_info |
OLD | NEW |