finally fixed colors

This commit is contained in:
Kyattsukuro 2026-03-31 12:01:49 +02:00
parent 26c1513148
commit cf4010c015
9 changed files with 27 additions and 9 deletions

View File

@ -0,0 +1 @@
,someone,nixMain,31.03.2026 11:57,file:///home/someone/.config/yolk/eggs/libreoffice/4;

Binary file not shown.

View File

@ -313,14 +313,20 @@ SPICIES = {
}
CATCHED_BY = {
"Nfg": [*add_cased_options("nfg")],
"Nfg": [*add_cased_options("nfg"),
*add_cased_options("nf")],
"KK": [*add_cased_options("kk"),
*add_cased_options("überwinterungskästen"),
*add_cased_options("kastenkontrolle"),
*add_cased_options("kasten")],
"WQK": [*add_cased_options("wqk"),
"WQK": [*add_cased_options("wqk"),
*add_cased_options("Winterquartierkontrolle"),
*add_cased_options("Winterquartierkasten"),
*add_cased_options("Winterquartier"),
*add_cased_options("kontrolle")],
"Wst": [*add_cased_options("wst")],
"Wst": [*add_cased_options("wst"),
*add_cased_options("Wochenstuben"),
*add_cased_options("Wochenstube")],
"AFZ": [*add_cased_options("afz")],
"Detektor": [*add_cased_options("detektor")],
}

View File

@ -76,6 +76,6 @@ ROW_INSTRUCTIONS = [
"approximate": True,
"threshold": "ANY", # ALL, ANY, MAJORITY of row must be collored
"target": "Wiederfunde",
"value": True,
"value": "WAHR",
}
]

View File

@ -59,7 +59,7 @@ def main():
args = parser.parse_args()
if args.v:
print("1.3")
print("1.4")
return
if not args.type:
parser.error("The --type argument is required.")

View File

@ -15,6 +15,10 @@ class FindAndReplace:
if self.require_full_match and bad_name == res:
# Todo remove random leading/trailing spaces before if
res = correct_name
break
elif not self.require_full_match:
prior_val = res
res = res.replace(bad_name, correct_name)
if prior_val != res or correct_name in res:
break
return Entry(value=res, fg_color=entry.fg_color, bg_color=entry.bg_color)

View File

@ -1,4 +1,11 @@
from fledermaus_formatter.table_handler.Entry import Entry
from math import sqrt
def div_from_color(given_rgb, reqiuired_rgb):
r, g, b = given_rgb
cr, cg, cb = reqiuired_rgb
color_diff = sqrt((r - cr)**2 + (g - cg)**2 + (b - cb)**2)
return color_diff
class RowColorToCalue:
def __init__(self, target: str,
@ -25,13 +32,13 @@ class RowColorToCalue:
def _check_if_collection_matchers(self, collectin: dict[tuple[int, int, int]], color_place: str) -> bool:
threshold_sq = 130 ** 2
threshold_sq = 120
res_map = []
if self.approximate:
for color in collectin:
is_match = any(
sum((a - b) ** 2 for a, b in zip(color, allowed_color)) <= threshold_sq
div_from_color(color, allowed_color) <= threshold_sq
for allowed_color in self.__dict__[color_place]
)
res_map.append(is_match)

View File

@ -56,8 +56,8 @@ class TableSerializer:
cell = row[ws_idx]
data[expected_col][rid] = Entry(
value=str(cell._value) if not cell.value is None else "",
bg_color=hex_to_rgb(cell.fill.start_color.rgb if cell.fill and cell.fill.start_color else "#0"),
fg_color=hex_to_rgb(cell.font.color.rgb if cell.font and cell.font.color else "#0")
bg_color=hex_to_rgb(cell.fill.end_color.rgb[2:] if cell.fill and cell.fill.start_color else "#0"),
fg_color=hex_to_rgb(cell.font.color.rgb[2:] if cell.font and cell.font.color and type(cell.font.color.rgb) == str else "#0")
)
return data

Binary file not shown.