Discover Serato smart crate definitions
This commit is contained in:
@@ -95,6 +95,7 @@ def main():
|
||||
print(f"Broken Symlinks: {health.broken_symlinks}")
|
||||
print(f"Static Crates: {health.static_crates}")
|
||||
print(f"Smart Crates: {health.smart_crates}")
|
||||
print(f"Smart Crate Containers: {health.smart_crate_containers}")
|
||||
print(
|
||||
f"Dynamic References Excluded: {health.dynamic_references_excluded}"
|
||||
)
|
||||
|
||||
@@ -103,9 +103,19 @@ def load_library_crates(
|
||||
serato_root: Path, reference_roots: Iterable[Path] = ()
|
||||
) -> Tuple[Crate, ...]:
|
||||
reference_roots = tuple(reference_roots)
|
||||
if not serato_root.is_dir():
|
||||
return ()
|
||||
|
||||
crates = []
|
||||
for folder_name in ("Subcrates", "Smartcrates"):
|
||||
folder = serato_root / folder_name
|
||||
for crate_path in folder.rglob("*.crate"):
|
||||
crates.append(load_crate(crate_path, reference_roots))
|
||||
folder_patterns = {
|
||||
"subcrates": ("*.crate",),
|
||||
"smartcrates": ("*.scrate", "*.crate"),
|
||||
}
|
||||
for folder in serato_root.iterdir():
|
||||
patterns = folder_patterns.get(folder.name.casefold())
|
||||
if patterns is None or not folder.is_dir():
|
||||
continue
|
||||
for pattern in patterns:
|
||||
for crate_path in folder.rglob(pattern):
|
||||
crates.append(load_crate(crate_path, reference_roots))
|
||||
return tuple(sorted(crates, key=lambda crate: str(crate.path)))
|
||||
|
||||
@@ -67,7 +67,12 @@ def analyze_health(library: Library) -> HealthReport:
|
||||
crate.kind is CrateKind.STATIC for crate in library.crates
|
||||
),
|
||||
smart_crates=sum(
|
||||
crate.kind is CrateKind.SMART for crate in library.crates
|
||||
crate.kind is CrateKind.SMART and crate.is_smart_definition
|
||||
for crate in library.crates
|
||||
),
|
||||
smart_crate_containers=sum(
|
||||
crate.kind is CrateKind.SMART and not crate.is_smart_definition
|
||||
for crate in library.crates
|
||||
),
|
||||
unknown_crates=sum(
|
||||
crate.kind is CrateKind.UNKNOWN for crate in library.crates
|
||||
|
||||
@@ -19,3 +19,15 @@ class Crate:
|
||||
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"
|
||||
|
||||
@@ -22,6 +22,7 @@ class HealthReport:
|
||||
broken_symlinks: int
|
||||
static_crates: int
|
||||
smart_crates: int
|
||||
smart_crate_containers: int
|
||||
unknown_crates: int
|
||||
dynamic_references_excluded: int
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
<div id="diagnostics" class="diagnostics panel">
|
||||
<div class="section-heading"><div><p class="eyebrow">Full picture</p><h2>Diagnostics</h2></div><span class="read-only-tag">No changes made</span></div>
|
||||
<div class="diagnostic-list">
|
||||
<div><span class="diag-icon violet">◇</span><p><strong>Crates</strong><small><b data-field="static_crates">—</b> static · <b data-field="smart_crates">—</b> smart · <b data-field="dynamic_references_excluded">—</b> dynamic references excluded</small></p></div>
|
||||
<div><span class="diag-icon violet">◇</span><p><strong>Crates</strong><small><b data-field="static_crates">—</b> static · <b data-field="smart_crates">—</b> smart · <b data-field="smart_crate_containers">—</b> dynamic containers · <b data-field="dynamic_references_excluded">—</b> references excluded</small></p></div>
|
||||
<div><span class="diag-icon amber">≋</span><p><strong>Duplicate filenames</strong><small><b data-field="duplicate_filename_groups">—</b> exact groups · <b data-field="duplicate_files">—</b> extra files</small></p></div>
|
||||
<div><span class="diag-icon blue">⌁</span><p><strong>Cloud conflicts</strong><small><b data-field="suspected_cloud_conflict_groups">—</b> suspected groups · <b data-field="suspected_cloud_conflict_files">—</b> extra files</small></p></div>
|
||||
<div><span class="diag-icon red">↗</span><p><strong>Broken symlinks</strong><small><b data-field="broken_symlinks">—</b> unresolved links</small></p></div>
|
||||
|
||||
Reference in New Issue
Block a user