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

Unified Diff: chrome/common/extensions/docs/server2/file_system.py

Issue 453713002: Docserver: Generate a table of extension/app API owners (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/file_system.py
diff --git a/chrome/common/extensions/docs/server2/file_system.py b/chrome/common/extensions/docs/server2/file_system.py
index 1e5b567dab59b3b1eea7229f2416ac8695fab1e2..1b49753cfb81c58aeee05e17ef70edd40752ac76 100644
--- a/chrome/common/extensions/docs/server2/file_system.py
+++ b/chrome/common/extensions/docs/server2/file_system.py
@@ -145,13 +145,14 @@ class FileSystem(object):
'''
raise NotImplementedError(self.__class__)
- def Walk(self, root):
+ def Walk(self, root, depth=-1):
'''Recursively walk the directories in a file system, starting with root.
Behaviour is very similar to os.walk from the standard os module, yielding
(base, dirs, files) recursively, where |base| is the base path of |files|,
|dirs| relative to |root|, and |files| and |dirs| the list of files/dirs in
- |base| respectively.
+ |base| respectively. If |depth| is specified and greater than 0, Walk will
not at google - send to devlin 2014/08/15 15:45:50 Quick test for specifying depth=0, 1, or 2 plz.
+ only recurse |depth| times.
Note that directories will always end with a '/', files never will.
@@ -161,7 +162,9 @@ class FileSystem(object):
AssertIsDirectory(root)
basepath = root
- def walk(root):
+ def walk(root, depth):
+ if depth == 0:
+ return
AssertIsDirectory(root)
dirs, files = [], []
@@ -174,10 +177,10 @@ class FileSystem(object):
yield root[len(basepath):].rstrip('/'), dirs, files
for d in dirs:
- for walkinfo in walk(root + d):
+ for walkinfo in walk(root + d, depth - 1):
yield walkinfo
- for walkinfo in walk(root):
+ for walkinfo in walk(root, depth):
yield walkinfo
def __eq__(self, other):

Powered by Google App Engine
This is Rietveld 408576698