Update ~script.py (#990)

Changing the boolean expression avoids the use of a continue statement.
This way the code becomes easier/faster to compute on lower level and it has a
better coding style.
This commit is contained in:
FrogBattle 2019-07-11 17:21:48 +01:00 committed by cclauss
parent c2f2fa8b23
commit f2eb965604

View File

@ -20,16 +20,15 @@ def _markdown(parent, ignores, ignores_ext, depth):
for i in os.listdir(parent): for i in os.listdir(parent):
full = os.path.join(parent, i) full = os.path.join(parent, i)
name, ext = os.path.splitext(i) name, ext = os.path.splitext(i)
if i in ignores or ext in ignores_ext: if i not in ignores and ext not in ignores_ext:
continue if os.path.isfile(full):
if os.path.isfile(full): # generate list
# generate list pre = parent.replace("./", "").replace(" ", "%20")
pre = parent.replace("./", "").replace(" ", "%20") # replace all spaces to safe URL
# replace all spaces to safe URL child = i.replace(" ", "%20")
child = i.replace(" ", "%20") files.append((pre, child, name))
files.append((pre, child, name)) else:
else: dirs.append(i)
dirs.append(i)
# Sort files # Sort files
files.sort(key=lambda e: e[2].lower()) files.sort(key=lambda e: e[2].lower())
for f in files: for f in files: