34 lines
775 B
Python
34 lines
775 B
Python
from dataclasses import dataclass
|
|
from enum import Enum
|
|
from pathlib import Path
|
|
from typing import Tuple
|
|
|
|
from serato_doctor.models.reference import TrackReference
|
|
|
|
|
|
class CrateKind(str, Enum):
|
|
STATIC = "static"
|
|
SMART = "smart"
|
|
UNKNOWN = "unknown"
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Crate:
|
|
"""A Serato crate and the track references parsed from it."""
|
|
|
|
path: Path
|
|
references: Tuple[TrackReference, ...]
|
|
kind: CrateKind = CrateKind.UNKNOWN
|
|
|
|
@property
|
|
def hierarchy(self) -> Tuple[str, ...]:
|
|
return tuple(self.path.stem.split("≫≫"))
|
|
|
|
@property
|
|
def display_name(self) -> str:
|
|
return self.hierarchy[-1]
|
|
|
|
@property
|
|
def is_smart_definition(self) -> bool:
|
|
return self.path.suffix.casefold() == ".scrate"
|