Skip to content
Snippets Groups Projects
Verified Commit f2a7e65b authored by Laurent Heirendt's avatar Laurent Heirendt :airplane:
Browse files

rewrite f

parent c294d541
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,16 @@ def line_prepender(filename, line):
f.seek(0, 0)
f.write(line.rstrip('\r\n') + '\n' + content)
def get_subdirs(p):
for fname in os.listdir(p):
if os.path.isdir(os.path.join(p, fname)):
yield os.path.join(p, fname)
def has_subdirs(p):
folders = list(get_subdirs(p))
return len(folders) != 0
def build_link(title, href):
# strip the number of the title
......@@ -155,15 +165,6 @@ def remove_header(localroot, root, filename):
return n
def folders_in(path_to_parent):
for fname in os.listdir(path_to_parent):
if os.path.isdir(os.path.join(path_to_parent, fname)):
yield os.path.join(path_to_parent, fname)
def has_folders(path_to_parent):
folders = list(folders_in(path_to_parent))
return len(folders) != 0
def element_header(prefix, permalink, element):
# handbook section
......@@ -241,12 +242,12 @@ sections = []
# determine first the directories
for direct in cardDirs:
if path.isdir(direct) and has_folders(direct):
if path.isdir(direct) and has_subdirs(direct):
dirs = os.listdir(direct)
dirs = natsorted(dirs)
for d in dirs:
if d[0] != "." and d not in ignore and has_folders(direct + "/" + d):
if d[0] != "." and d not in ignore and has_subdirs(direct + "/" + d):
sections.append(d)
sections = list(set(sections))
......@@ -270,7 +271,7 @@ for folder in cardDirs:
dirs = natsorted(dirs)
for d in dirs:
if d[0] != "." and d not in ignore and has_folders(folder + "/" + d):
if d[0] != "." and d not in ignore and has_subdirs(folder + "/" + d):
# set the header of the section
#index += "\n### " + d.replace("-", " ").capitalize() + "\n"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment