Skip to content
Snippets Groups Projects
Commit 58c9c7fa authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

FIX: Better implementation of split_restricted_path that fixes an error. Also...

FIX: Better implementation of split_restricted_path that fixes an error. Also added some documentation.
parent 6de4abad
Branches
Tags
2 merge requests!160STY: styling,!127More documentation (docstrings) of parameters add/remove_prefix and restricted_path
Pipeline #39818 passed with warnings
...@@ -1402,12 +1402,18 @@ def parse_args(): ...@@ -1402,12 +1402,18 @@ def parse_args():
def split_restricted_path(path): def split_restricted_path(path):
elements = [] """
while path != "/": Split a path string into components separated by slashes or other os.path.sep.
path, el = os.path.split(path) Empty elements will be removed.
if el != "": """
elements.insert(0, el) # This implementation leads to infinite loops
return elements # for "ill-posed" paths (see test_utilities.py"):
# elements = []
# while path != "/":
# path, el = os.path.split(path)
# if el != "":
# elements.insert(0, el)
return [i for i in path.split(os.path.sep) if i != ""]
def main(): def main():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment