diff --git a/data/.~lock.ringe_short.xlsx# b/data/.~lock.ringe_short.xlsx# new file mode 100644 index 0000000..013ddb9 --- /dev/null +++ b/data/.~lock.ringe_short.xlsx# @@ -0,0 +1 @@ +,someone,nixMain,31.03.2026 11:57,file:///home/someone/.config/yolk/eggs/libreoffice/4; \ No newline at end of file diff --git a/data/ringe_short.xlsx b/data/ringe_short.xlsx index 312442b..795a686 100644 Binary files a/data/ringe_short.xlsx and b/data/ringe_short.xlsx differ diff --git a/fledermaus_formatter/instructions/mappings.py b/fledermaus_formatter/instructions/mappings.py index 03bf651..b6f8bb5 100644 --- a/fledermaus_formatter/instructions/mappings.py +++ b/fledermaus_formatter/instructions/mappings.py @@ -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")], } diff --git a/fledermaus_formatter/instructions/ring_formater.py b/fledermaus_formatter/instructions/ring_formater.py index 9dbe12e..839a43d 100644 --- a/fledermaus_formatter/instructions/ring_formater.py +++ b/fledermaus_formatter/instructions/ring_formater.py @@ -76,6 +76,6 @@ ROW_INSTRUCTIONS = [ "approximate": True, "threshold": "ANY", # ALL, ANY, MAJORITY of row must be collored "target": "Wiederfunde", - "value": True, + "value": "WAHR", } ] \ No newline at end of file diff --git a/fledermaus_formatter/main.py b/fledermaus_formatter/main.py index 1415e12..059d2d0 100644 --- a/fledermaus_formatter/main.py +++ b/fledermaus_formatter/main.py @@ -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.") diff --git a/fledermaus_formatter/table_handler/commands/find_and_replace.py b/fledermaus_formatter/table_handler/commands/find_and_replace.py index bfbd21e..67b2828 100644 --- a/fledermaus_formatter/table_handler/commands/find_and_replace.py +++ b/fledermaus_formatter/table_handler/commands/find_and_replace.py @@ -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) \ No newline at end of file diff --git a/fledermaus_formatter/table_handler/commands/row_color_to_value.py b/fledermaus_formatter/table_handler/commands/row_color_to_value.py index c33007f..96679c4 100644 --- a/fledermaus_formatter/table_handler/commands/row_color_to_value.py +++ b/fledermaus_formatter/table_handler/commands/row_color_to_value.py @@ -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) diff --git a/fledermaus_formatter/table_handler/serializer.py b/fledermaus_formatter/table_handler/serializer.py index cb85b2b..994b436 100644 --- a/fledermaus_formatter/table_handler/serializer.py +++ b/fledermaus_formatter/table_handler/serializer.py @@ -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 diff --git a/ringe_short_out.xlsx b/ringe_short_out.xlsx index 67047eb..f52f388 100644 Binary files a/ringe_short_out.xlsx and b/ringe_short_out.xlsx differ