From a5c8e6f051eb03a500e1641d16547ea1bdc5f5e1 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Fri, 11 Nov 2022 07:57:56 +0100 Subject: [PATCH] removed dots from the beginning of files and paths tu unhide file system elements on linux/unix like systems --- src/url_to_path.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/url_to_path.py b/src/url_to_path.py index dd4a28f..70868ad 100644 --- a/src/url_to_path.py +++ b/src/url_to_path.py @@ -1,6 +1,16 @@ import os.path import logging +UNHIDE_CHAR = ',' + +def unhide(part: str): + if len(part) == 0: + return "" + if part[0] == ".": + part[0] = UNHIDE_CHAR + + return part + class UrlPath: def __init__(self, database, logger: logging.Logger, genre: str): @@ -25,7 +35,7 @@ class UrlPath: self.get_album(row)) def escape_part(self, part: str): - return part.replace("/", " ") + return unhide(part.replace("/", " ")) def get_genre(self): return self.escape_part(self.genre)