userland: allow selecting targets, including directories

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-03-13 00:00:02 +00:00
parent cbf6481c4b
commit 276688bb33
7 changed files with 91 additions and 71 deletions

View File

@@ -310,6 +310,19 @@ class ShellHelpers:
else:
os.unlink(path)
def walk(self, root):
'''
Extended walk that can take files or directories.
'''
if not os.path.exists(root):
raise Exception('Path does not exist: ' + root)
if os.path.isfile(root):
dirname, basename = os.path.split(root)
yield dirname, [], [basename]
else:
for path, dirnames, filenames in os.walk(root):
yield path, dirnames, filenames
def wget(self, url, download_path):
'''
Append extra KEY=val configs into the given config file.