From b2d890466b61bf61bd70f6f8bce637dddd93b353 Mon Sep 17 00:00:00 2001 From: Ren Tatsumoto Date: Wed, 5 Jun 2024 17:14:10 +0300 Subject: [PATCH] expand replace patterns --- kitsunekko_tools/common.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kitsunekko_tools/common.py b/kitsunekko_tools/common.py index 1e84863..03e456a 100644 --- a/kitsunekko_tools/common.py +++ b/kitsunekko_tools/common.py @@ -13,7 +13,13 @@ def what(self) -> str: RE_FILENAME_PROHIBITED = re.compile(r"[ _\\\n\t\r#\[\]{}<>^*/:`?'|]+", flags=re.MULTILINE | re.IGNORECASE) +RE_MULTI_SPACE = re.compile(r" {2,}", flags=re.MULTILINE | re.IGNORECASE) def fs_name_strip(name: str) -> str: - return re.sub(RE_FILENAME_PROHIBITED, " ", name.replace(":", ".")).strip() + name = name.replace(":", ".") + name = name.replace("??", "2") + name = name.replace("||", "2") + name = re.sub(RE_FILENAME_PROHIBITED, " ", name) + name = re.sub(RE_MULTI_SPACE, " ", name) + return name.strip()