Verified Commit f2c0e5a4 authored by Jakob Moser's avatar Jakob Moser
Browse files

Import skeleton of organization

parent b7313398
Loading
Loading
Loading
Loading
+18 −0
Changes for karaokatalog/instructions/MoveInstruction.py: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
from dataclasses import dataclass
from pathlib import Path

from karaokatalog.instructions.Instruction import Instruction


@dataclass(frozen=True)
class MoveInstruction(Instruction):
    """
    Move the old path (might point to a file, a folder or a link) to the new path, no questions asked.
    Does not override existing paths.
    """

    old_path: Path
    new_path: Path

    def __call__(self) -> None:
        raise NotImplementedError()  # TODO
+11 −1
Changes for karaokatalog/organize/__main__.py: 11 added lines, 1 removed line.
Original line number Diff line number Diff line
import logging

from tqdm import tqdm

from karaokatalog.get_parser import get_parser
from karaokatalog.Library import Library
from karaokatalog.organize.move import move

logging.basicConfig(
    format="%(asctime)s [%(levelname)s] %(message)s", level=logging.INFO
@@ -18,6 +21,13 @@ if __name__ == "__main__":
    library = Library.from_dir(args.library_path)
    logging.info("Library loaded")

    # TODO
    logging.info("Generating move instructions")
    move_instructions = move(library.songs, args.library_path)
    logging.info(f"{len(move_instructions)} move instructions generated")

    logging.warning(f"Moving {len(move_instructions)} songs!")
    for instruction in tqdm(move_instructions, unit=" songs"):
        instruction()
    logging.info("Moving done")

    logging.info("Karaokatalog Organization done")
+13 −0
Changes for karaokatalog/organize/move.py: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
from collections.abc import Sequence
from pathlib import Path

from karaokatalog.instructions.MoveInstruction import MoveInstruction
from karaokatalog.Song import Song


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.
    """
    raise NotImplementedError()  # TODO