From 4cef99cb55db348c516adcbd77bb4c8d087c02a2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 11 Jun 2020 23:04:41 +0100 Subject: [PATCH] Tidying --- shares.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/shares.py b/shares.py index 77dca560..11cf7c34 100644 --- a/shares.py +++ b/shares.py @@ -23,12 +23,15 @@ def getValidSharedItemID(displayName: str) -> str: """Removes any invalid characters from the display name to produce an item ID """ - displayName = displayName.replace(' ', '').replace('+', '-') - displayName = displayName.replace('/', '-').replace('\\', '-') - displayName = displayName.replace('.', '_').replace('?', '-') - displayName = displayName.replace('\n', '').replace('\r', '') + removeChars = (' ', '\n', '\r') + for ch in removeChars: + displayName = displayName.replace(ch, '') + removeChars2 = ('+', '/', '\\', '?', '&') + for ch in removeChars2: + displayName = displayName.replace(ch, '-') + displayName = displayName.replace('.', '_') displayName = displayName.replace("’", "'") - return displayName.replace('&', '-') + return displayName def removeShare(baseDir: str, nickname: str, domain: str,