Verified Commit 2ffae9ce authored by Jakob Moser's avatar Jakob Moser
Browse files

Strip trailing dots, document those measures

parent 4c00b01c
Loading
Loading
Loading
Loading
+8 −1
Changes for karaokatalog/organize/move.py: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -7,7 +7,11 @@ from tqdm import tqdm
from karaokatalog.instructions.MoveInstruction import MoveInstruction
from karaokatalog.Song import Song

FORBIDDEN_CHARACTERS = re.compile(r'[\/<>:"\\|?*]')
# Those characters are forbidden on Linux (few) or on Windows (many), so we strip them from filenames
# https://stackoverflow.com/a/31976060/
# Apparently, trailing dots are also prohibited, so we strip those as well:
# https://lkml.iu.edu/hypermail/linux/kernel/2203.2/01877.html
FORBIDDEN_CHARACTERS = re.compile(r'[\/<>:"\\|?*]|\.$')


def _get_canonical_song_dir(song: Song, variant: int = 0) -> Path:
@@ -28,6 +32,9 @@ def move(songs: Sequence[Song], base_dir: Path) -> Sequence[MoveInstruction]:
    Create move instructions to move every song into the proper song directory
    within the given base_dir.
    """

    # We lower case all the song directories, because Windows filesystems are often
    # case-insensitive, so we have to ignore casing when finding duplicates
    song_dir_strs_lower = set(
        str(song.dir.relative_to(base_dir)).lower() for song in songs
    )