Chromium Code Reviews| 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 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 xml.dom.minidom as xml | 9 import xml.dom.minidom as xml |
| 10 from xml.parsers.expat import ExpatError | 10 from xml.parsers.expat import ExpatError |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 # All versions in StatInfo need to be strings. | 111 # All versions in StatInfo need to be strings. |
| 112 return StatInfo(str(parent_version), | 112 return StatInfo(str(parent_version), |
| 113 dict((path, str(version)) | 113 dict((path, str(version)) |
| 114 for path, version in child_versions.iteritems())) | 114 for path, version in child_versions.iteritems())) |
| 115 | 115 |
| 116 # Bleh, but, this data is so unreliable. There are actually some empty file | 116 # 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. | 117 # listings caused by git/svn/something not cleaning up empty dirs. |
| 118 return StatInfo('0', {}) | 118 return StatInfo('0', {}) |
| 119 | 119 |
| 120 def Stat(self, path): | 120 def Stat(self, path): |
| 121 directory = path.rsplit('/', 1)[0] | 121 if '/' in path: |
| 122 directory, filename = path.rsplit('/', 1) | |
|
Yoyo Zhou
2013/05/03 20:01:24
How about os.path.dirname and os.path.basename?
not at google - send to devlin
2013/05/03 20:41:25
Except these are URLs not paths, so needs to be ex
Yoyo Zhou
2013/05/03 20:52:47
The os.path functions seem to work just fine on UR
not at google - send to devlin
2013/05/03 21:06:49
did you test on windows?
| |
| 123 else: | |
| 124 directory, filename = ('', path) | |
| 122 result = self._stat_fetcher.Fetch(directory + '/') | 125 result = self._stat_fetcher.Fetch(directory + '/') |
| 123 if result.status_code == 404: | 126 if result.status_code == 404: |
| 124 raise FileNotFoundError( | 127 raise FileNotFoundError( |
| 125 'Got 404 when fetching %s from %s for Stat' % (path, directory)) | 128 'Got 404 when fetching %s from %s for Stat' % (path, directory)) |
| 126 stat_info = self._CreateStatInfo(result.content) | 129 stat_info = self._CreateStatInfo(result.content) |
| 127 if not path.endswith('/'): | 130 if path.endswith('/'): |
| 128 filename = path.rsplit('/', 1)[-1] | 131 return stat_info |
| 129 if filename not in stat_info.child_versions: | 132 if filename not in stat_info.child_versions: |
| 130 raise FileNotFoundError('%s was not in child versions' % filename) | 133 raise FileNotFoundError('%s was not in child versions' % filename) |
| 131 stat_info.version = stat_info.child_versions[filename] | 134 return StatInfo(stat_info.child_versions[filename]) |
| 132 return stat_info | |
| OLD | NEW |