Show More
@@ -380,6 +380,22 b' class abstractvfs(object):' | |||||
380 | def utime(self, path=None, t=None): |
|
380 | def utime(self, path=None, t=None): | |
381 | return os.utime(self.join(path), t) |
|
381 | return os.utime(self.join(path), t) | |
382 |
|
382 | |||
|
383 | def walk(self, path=None, onerror=None): | |||
|
384 | """Yield (dirpath, dirs, files) tuple for each directories under path | |||
|
385 | ||||
|
386 | ``dirpath`` is relative one from the root of this vfs. This | |||
|
387 | uses ``os.sep`` as path separator, even you specify POSIX | |||
|
388 | style ``path``. | |||
|
389 | ||||
|
390 | "The root of this vfs" is represented as empty ``dirpath``. | |||
|
391 | """ | |||
|
392 | root = os.path.normpath(self.join(None)) | |||
|
393 | # when dirpath == root, dirpath[prefixlen:] becomes empty | |||
|
394 | # because len(dirpath) < prefixlen. | |||
|
395 | prefixlen = len(pathutil.normasprefix(root)) | |||
|
396 | for dirpath, dirs, files in os.walk(self.join(path), onerror=onerror): | |||
|
397 | yield (dirpath[prefixlen:], dirs, files) | |||
|
398 | ||||
383 | class vfs(abstractvfs): |
|
399 | class vfs(abstractvfs): | |
384 | '''Operate files relative to a base directory |
|
400 | '''Operate files relative to a base directory | |
385 |
|
401 |
General Comments 0
You need to be logged in to leave comments.
Login now