From e916ccea923a24fe6b72b2a722a3a495f4e6f025 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Tue, 21 Aug 2018 08:19:43 +1000 Subject: [PATCH] Remove trailing spaces in folder names --- major_projects_grabber/major_projects_grabber.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/major_projects_grabber/major_projects_grabber.py b/major_projects_grabber/major_projects_grabber.py index ae2fd80..ac61a0f 100644 --- a/major_projects_grabber/major_projects_grabber.py +++ b/major_projects_grabber/major_projects_grabber.py @@ -25,8 +25,11 @@ from requests.exceptions import ConnectionError, InvalidURL def make_safe(s): """Remove characters that would be invalid in a filepath""" + # Remove trailing spaces + s_safe = s.strip() + # Remove '\', '*', '"', '<', '>' '|' - s_safe = re.sub('\\\|\*|"|<|>\|', '', s) + s_safe = re.sub('\\\|\*|"|<|>\|', '', s_safe) # Replace '/' and ':' with '-' s_safe = re.sub(':', ' -', s_safe)