24 lines
589 B
Python
24 lines
589 B
Python
from flatfilecms.models import Folder
|
|
|
|
|
|
def flat(d, path):
|
|
structure = []
|
|
for k, v in d.items():
|
|
if isinstance(v, dict):
|
|
structure.extend(flat(v, f"{path}/{k}"))
|
|
else:
|
|
if k == 'index':
|
|
structure.append(f"{path}/")
|
|
else:
|
|
structure.append(f"{path}/{k}")
|
|
return structure
|
|
|
|
|
|
class Root(Folder):
|
|
def __init__(self, path, data_path):
|
|
self.data_path = data_path
|
|
super(Root, self).__init__('', None, path)
|
|
|
|
def structure(self, base_dir=''):
|
|
return flat(self, base_dir)
|