def build_navigation(self, fspath): |
nav = H.Navigation(class_='sidebar') |
-> relpath = fspath.relto(self.projroot) |
path = relpath.split(os.path.sep) |
indent = 0 |
|
if relpath != '': |
for i in xrange(len(path)): |
dirpath = os.path.sep.join(path[:i]) |
abspath = self.projroot.join(dirpath).strpath |
if i == 0: |
text = self.projroot.basename |
else: |
text = path[i-1] |
nav.append(H.NavigationItem(self.linker, abspath, text, |
indent, False)) |
indent += 1 |
|
if fspath.check(dir=True): |
|
dirpath = fspath |
nav.append(H.NavigationItem(self.linker, dirpath.strpath, |
dirpath.basename, indent, True)) |
indent += 1 |
elif fspath.strpath == self.projroot.strpath: |
dirpath = fspath |
else: |
|
dirpath = fspath.dirpath() |
diritems, fileitems = source_dirs_files(dirpath) |
for dir in diritems: |
nav.append(H.NavigationItem(self.linker, dir.strpath, dir.basename, |
indent, False)) |
for file in fileitems: |
selected = (fspath.check(file=True) and |
file.basename == fspath.basename) |
nav.append(H.NavigationItem(self.linker, file.strpath, |
file.basename, indent, selected)) |
return nav |