finally fixed colors
This commit is contained in:
parent
26c1513148
commit
9b377dd9af
1
data/.~lock.ringe_short.xlsx#
Normal file
1
data/.~lock.ringe_short.xlsx#
Normal file
@ -0,0 +1 @@
|
|||||||
|
,someone,nixMain,31.03.2026 11:57,file:///home/someone/.config/yolk/eggs/libreoffice/4;
|
||||||
Binary file not shown.
@ -313,14 +313,20 @@ SPICIES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CATCHED_BY = {
|
CATCHED_BY = {
|
||||||
"Nfg": [*add_cased_options("nfg")],
|
"Nfg": [*add_cased_options("nfg"),
|
||||||
|
*add_cased_options("nf")],
|
||||||
"KK": [*add_cased_options("kk"),
|
"KK": [*add_cased_options("kk"),
|
||||||
*add_cased_options("überwinterungskästen"),
|
*add_cased_options("überwinterungskästen"),
|
||||||
*add_cased_options("kastenkontrolle"),
|
*add_cased_options("kastenkontrolle"),
|
||||||
*add_cased_options("kasten")],
|
*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")],
|
*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")],
|
"AFZ": [*add_cased_options("afz")],
|
||||||
"Detektor": [*add_cased_options("detektor")],
|
"Detektor": [*add_cased_options("detektor")],
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,6 +76,6 @@ ROW_INSTRUCTIONS = [
|
|||||||
"approximate": True,
|
"approximate": True,
|
||||||
"threshold": "ANY", # ALL, ANY, MAJORITY of row must be collored
|
"threshold": "ANY", # ALL, ANY, MAJORITY of row must be collored
|
||||||
"target": "Wiederfunde",
|
"target": "Wiederfunde",
|
||||||
"value": True,
|
"value": "WAHR",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -15,6 +15,10 @@ class FindAndReplace:
|
|||||||
if self.require_full_match and bad_name == res:
|
if self.require_full_match and bad_name == res:
|
||||||
# Todo remove random leading/trailing spaces before if
|
# Todo remove random leading/trailing spaces before if
|
||||||
res = correct_name
|
res = correct_name
|
||||||
|
break
|
||||||
elif not self.require_full_match:
|
elif not self.require_full_match:
|
||||||
|
prior_val = res
|
||||||
res = res.replace(bad_name, correct_name)
|
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)
|
return Entry(value=res, fg_color=entry.fg_color, bg_color=entry.bg_color)
|
||||||
@ -1,4 +1,11 @@
|
|||||||
from fledermaus_formatter.table_handler.Entry import Entry
|
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:
|
class RowColorToCalue:
|
||||||
def __init__(self, target: str,
|
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:
|
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 = []
|
res_map = []
|
||||||
if self.approximate:
|
if self.approximate:
|
||||||
for color in collectin:
|
for color in collectin:
|
||||||
is_match = any(
|
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]
|
for allowed_color in self.__dict__[color_place]
|
||||||
)
|
)
|
||||||
res_map.append(is_match)
|
res_map.append(is_match)
|
||||||
|
|||||||
@ -56,8 +56,8 @@ class TableSerializer:
|
|||||||
cell = row[ws_idx]
|
cell = row[ws_idx]
|
||||||
data[expected_col][rid] = Entry(
|
data[expected_col][rid] = Entry(
|
||||||
value=str(cell._value) if not cell.value is None else "",
|
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"),
|
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 if cell.font and cell.font.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
|
return data
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user