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
No related branches found
No related tags found
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():
def split_restricted_path(path):
elements = []
while path != "/":
path, el = os.path.split(path)
if el != "":
elements.insert(0, el)
return elements
"""
Split a path string into components separated by slashes or other os.path.sep.
Empty elements will be removed.
"""
# This implementation leads to infinite loops
# 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():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment