Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (C) 2009 Google Inc. All rights reserved. | 1 # Copyright (C) 2009 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 if comps[-1] == '' and path: | 198 if comps[-1] == '' and path: |
| 199 path += '/' | 199 path += '/' |
| 200 path = path.replace(sep + sep, sep) | 200 path = path.replace(sep + sep, sep) |
| 201 return path | 201 return path |
| 202 | 202 |
| 203 def listdir(self, path): | 203 def listdir(self, path): |
| 204 root, dirs, files = list(self.walk(path))[0] | 204 root, dirs, files = list(self.walk(path))[0] |
| 205 return dirs + files | 205 return dirs + files |
| 206 | 206 |
| 207 def walk(self, top): | 207 def walk(self, top): |
| 208 FILE_SYSTEM_TUPLES = [] | |
|
qyearsley
2016/06/01 23:08:43
Non-global variable names use lowercase with under
| |
| 208 sep = self.sep | 209 sep = self.sep |
| 209 if not self.isdir(top): | 210 if not self.isdir(top): |
| 210 raise OSError("%s is not a directory" % top) | 211 raise OSError("%s is not a directory" % top) |
| 211 | 212 |
| 212 if not top.endswith(sep): | 213 if not top.endswith(sep): |
| 213 top += sep | 214 top += sep |
| 214 | 215 |
| 215 dirs = [] | 216 dirs = [] |
| 216 files = [] | 217 files = [] |
| 217 for f in self.files: | 218 for f in self.files: |
| 218 if self.exists(f) and f.startswith(top): | 219 if self.exists(f) and f.startswith(top): |
| 219 remaining = f[len(top):] | 220 remaining = f[len(top):] |
| 220 if sep in remaining: | 221 if sep in remaining: |
| 221 dir = remaining[:remaining.index(sep)] | 222 dir = remaining[:remaining.index(sep)] |
| 222 if not dir in dirs: | 223 if not dir in dirs: |
| 223 dirs.append(dir) | 224 dirs.append(dir) |
| 224 else: | 225 else: |
| 225 files.append(remaining) | 226 files.append(remaining) |
| 226 return [(top[:-1], dirs, files)] | 227 FILE_SYSTEM_TUPLES = [(top[:-1], dirs, files)] |
| 228 for dir in dirs: | |
| 229 dir = top + dir | |
| 230 subdir = self.walk(dir) | |
|
qyearsley
2016/06/01 23:08:43
This variable name could probably be improved; is
| |
| 231 FILE_SYSTEM_TUPLES += subdir | |
| 232 return FILE_SYSTEM_TUPLES | |
| 227 | 233 |
| 228 def mtime(self, path): | 234 def mtime(self, path): |
| 229 if self.exists(path): | 235 if self.exists(path): |
| 230 return 0 | 236 return 0 |
| 231 self._raise_not_found(path) | 237 self._raise_not_found(path) |
| 232 | 238 |
| 233 def _mktemp(self, suffix='', prefix='tmp', dir=None, **kwargs): | 239 def _mktemp(self, suffix='', prefix='tmp', dir=None, **kwargs): |
| 234 if dir is None: | 240 if dir is None: |
| 235 dir = self.sep + '__im_tmp' | 241 dir = self.sep + '__im_tmp' |
| 236 curno = self.current_tmpno | 242 curno = self.current_tmpno |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 return self.data.readline(length) | 491 return self.data.readline(length) |
| 486 | 492 |
| 487 def __iter__(self): | 493 def __iter__(self): |
| 488 return self.data.__iter__() | 494 return self.data.__iter__() |
| 489 | 495 |
| 490 def next(self): | 496 def next(self): |
| 491 return self.data.next() | 497 return self.data.next() |
| 492 | 498 |
| 493 def seek(self, offset, whence=os.SEEK_SET): | 499 def seek(self, offset, whence=os.SEEK_SET): |
| 494 self.data.seek(offset, whence) | 500 self.data.seek(offset, whence) |
| OLD | NEW |