@@ -1,13 +1,15 @@
|
|||||||
"""Inspect photos selected in Photos """
|
"""Inspect photos selected in Photos """
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
import pathlib
|
||||||
import re
|
import re
|
||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
from multiprocessing import Process, Queue
|
from multiprocessing import Process, Queue
|
||||||
from queue import Empty
|
from queue import Empty
|
||||||
from time import gmtime, sleep, strftime
|
from time import gmtime, sleep, strftime
|
||||||
from typing import List, Optional, Tuple
|
from typing import Generator, List, Optional, Tuple
|
||||||
import pathlib
|
|
||||||
|
|
||||||
import bitmath
|
import bitmath
|
||||||
import click
|
import click
|
||||||
@@ -35,6 +37,17 @@ bold = add_rich_markup_tag("bold")
|
|||||||
dim = add_rich_markup_tag("dim")
|
dim = add_rich_markup_tag("dim")
|
||||||
|
|
||||||
|
|
||||||
|
def add_cyclic_color_tag(values: list[str]) -> Generator[str, None, None]:
|
||||||
|
"""Add a rich markup tag to each str in values, cycling through a set of colors"""
|
||||||
|
# reuse some colors already in the theme
|
||||||
|
# these are chosen for contrast to easily associate scores and values
|
||||||
|
colors = ["change", "count", "filepath", "filename"]
|
||||||
|
color_tags = [add_rich_markup_tag(color) for color in colors]
|
||||||
|
modidx = len(color_tags)
|
||||||
|
for idx, val in enumerate(values):
|
||||||
|
yield color_tags[idx % modidx](val)
|
||||||
|
|
||||||
|
|
||||||
def extract_uuid(text: str) -> str:
|
def extract_uuid(text: str) -> str:
|
||||||
"""Extract a UUID from a string"""
|
"""Extract a UUID from a string"""
|
||||||
if match := re.search(
|
if match := re.search(
|
||||||
@@ -191,9 +204,15 @@ def format_templates(photo: PhotoInfo, templates: List[str]) -> str:
|
|||||||
|
|
||||||
def format_score_info(photo: PhotoInfo) -> str:
|
def format_score_info(photo: PhotoInfo) -> str:
|
||||||
"""Format score_info"""
|
"""Format score_info"""
|
||||||
score_str = bold("Score: ")
|
score_str = bold("Scores: ")
|
||||||
if photo.score:
|
if photo.score:
|
||||||
score_str += f"[num]{photo.score.overall}[/]" if photo.score else "-"
|
# add color tags to each key: value pair to easily associate keys/values
|
||||||
|
score_values = add_cyclic_color_tag(
|
||||||
|
[f"{k}: {float(v):.2f}" for k, v in photo.score.asdict().items()]
|
||||||
|
)
|
||||||
|
score_str += ", ".join(score_values)
|
||||||
|
else:
|
||||||
|
score_str += "-"
|
||||||
return score_str
|
return score_str
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
""" ScoreInfo class to expose computed score info from the library """
|
""" ScoreInfo class to expose computed score info from the library """
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass, asdict
|
||||||
|
|
||||||
from ._constants import _PHOTOS_4_VERSION
|
from ._constants import _PHOTOS_4_VERSION
|
||||||
|
|
||||||
@@ -38,3 +38,7 @@ class ScoreInfo:
|
|||||||
well_chosen_subject: float
|
well_chosen_subject: float
|
||||||
well_framed_subject: float
|
well_framed_subject: float
|
||||||
well_timed_shot: float
|
well_timed_shot: float
|
||||||
|
|
||||||
|
def asdict(self):
|
||||||
|
"""Return ScoreInfo as a dict"""
|
||||||
|
return asdict(self)
|
||||||
|
|||||||
Reference in New Issue
Block a user