Skip to content

Commit

Permalink
Automatic backup 2024-03-15
Browse files Browse the repository at this point in the history
  • Loading branch information
snejus committed Mar 16, 2024
1 parent 112dd58 commit 7148843
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rich_tables/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
diff,
duration2human,
fmt_time,
format_string,
format_with_color,
format_with_color_on_black,
get_country,
Expand Down Expand Up @@ -134,6 +135,7 @@ def counts_table(data: List[JSONDict]) -> Table:
if isinstance(x, Iterable) and not isinstance(x, str)
else str(x)
),
category=lambda x: "/".join(map(format_with_color, x.split("/"))),
country=get_country,
helicopta=lambda x: ":fire: " if x and int(x) else "",
hidden=lambda x: ":shit: " if x and int(x) else "",
Expand All @@ -145,7 +147,7 @@ def counts_table(data: List[JSONDict]) -> Table:
),
released=lambda x: x.replace("-00", "") if isinstance(x, str) else str(x),
duration=lambda x: duration2human(x) if isinstance(x, (int, float)) else x,
total_duration=lambda x: duration2human(x),
# total_duration=duration2human,
plays=lambda x: wrap(x, BOLD_GREEN),
skips=lambda x: wrap(x, BOLD_RED),
# body=lambda x: x + "\n",
Expand Down Expand Up @@ -192,7 +194,7 @@ def counts_table(data: List[JSONDict]) -> Table:
"brand",
"calendar",
"catalognum",
"category",
# "category",
"categories",
"Category",
"code",
Expand Down Expand Up @@ -317,6 +319,9 @@ def _get_val(value: Any, field: str) -> Any:
if value is None:
value = "None"

if isinstance(value, str):
value = format_string(value)

if field not in FIELDS_MAP and field.endswith("_group") and isinstance(value, list):
return format_with_color(value)

Expand Down

0 comments on commit 7148843

Please sign in to comment.