Skip to content

Commit

Permalink
refactored split_list_arg()
Browse files Browse the repository at this point in the history
  • Loading branch information
rjwignar committed Dec 7, 2023
1 parent 4cfac55 commit fee86da
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions run-clang-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,26 +250,27 @@ def normalize_paths(paths):
"features/Test\ Features/feature.cpp" => "features/Test Features/feature.cpp"
"""
return [path.replace("\\","") for path in paths]

def split_list_arg(arg):
"""
If arg is a list containing a single argument it is split into multiple elements.
Otherwise it is returned unchanged
Workaround for GHA not allowing list arguments
"""
pattern = r'(?<!\\)\s+'
if len(arg) == 1:
# split list by regex
paths = re.split(pattern, arg[0])
print(paths)
paths = normalize_paths(paths)
# for path in paths:
# print(path)
# # normalize paths by removing forward slashes
# path = path.replace("\\", "dfgdf")
# print(path)
print(paths)
return paths
return arg[0].split() if len(arg) == 1 else arg
# if len(arg) == 1:
# # split list by regex
# paths = re.split(pattern, arg[0])
# print(paths)
# paths = normalize_paths(paths)
# # for path in paths:
# # print(path)
# # # normalize paths by removing forward slashes
# # path = path.replace("\\", "dfgdf")
# # print(path)
# print(paths)
# return paths
return normalize_paths(re.split(pattern, arg[0])) if len(arg) == 1 else arg


def main():
Expand Down

0 comments on commit fee86da

Please sign in to comment.