20 lines
506 B
Python
20 lines
506 B
Python
from misc import path_join
|
|
|
|
def _flatten_dirs(content, path=""):
|
|
for item in content:
|
|
item["name"] = path_join(path, item["name"])
|
|
if item["is_file"]:
|
|
yield item
|
|
else:
|
|
yield from _flatten_dirs(item["content"], item["name"])
|
|
del item["content"]
|
|
yield item
|
|
|
|
def flatten_dirs(content, path=""):
|
|
dirs = _flatten_dirs(content, path=path)
|
|
|
|
output = {}
|
|
for item in dirs:
|
|
output[item["name"]] = item
|
|
return output
|