fixed widerfunde, using raw entrypoint
This commit is contained in:
parent
0ad40077ea
commit
17d8ac3def
1
.~lock.ringe_short_out.xlsx#
Normal file
1
.~lock.ringe_short_out.xlsx#
Normal file
@ -0,0 +1 @@
|
|||||||
|
,someone,nixLap,30.03.2026 10:11,file:///home/someone/.config/yolk/eggs/libreoffice/4;
|
||||||
1
data/.~lock.ringe.xlsx#
Normal file
1
data/.~lock.ringe.xlsx#
Normal file
@ -0,0 +1 @@
|
|||||||
|
,someone,nixLap,30.03.2026 10:01,file:///home/someone/.config/yolk/eggs/libreoffice/4;
|
||||||
1
data/.~lock.ringe_short.xlsx#
Normal file
1
data/.~lock.ringe_short.xlsx#
Normal file
@ -0,0 +1 @@
|
|||||||
|
,someone,nixLap,30.03.2026 10:00,file:///home/someone/.config/yolk/eggs/libreoffice/4;
|
||||||
BIN
data/ringe.xlsx
BIN
data/ringe.xlsx
Binary file not shown.
Binary file not shown.
@ -74,8 +74,8 @@ ROW_INSTRUCTIONS = [
|
|||||||
"command": "ROW_COLOR_TO_BOOL", # Match when found as text color in any col of the row
|
"command": "ROW_COLOR_TO_BOOL", # Match when found as text color in any col of the row
|
||||||
"fg_colors": [(255,0,0), (0,0,255)],
|
"fg_colors": [(255,0,0), (0,0,255)],
|
||||||
"approximate": True,
|
"approximate": True,
|
||||||
"threshold": "ALL", # ALL, ANY, MAJORITY of row must be collored
|
"threshold": "MAJORITY", # ALL, ANY, MAJORITY of row must be collored
|
||||||
"target": "Wiederfunde",
|
"target": "Wiederfunde",
|
||||||
"value": "TRUE",
|
"value": True,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -13,9 +13,9 @@ class RowColorToCalue:
|
|||||||
self.fg_color = fg_colors if fg_colors else []
|
self.fg_color = fg_colors if fg_colors else []
|
||||||
self.bg_color = bg_colors if bg_colors else []
|
self.bg_color = bg_colors if bg_colors else []
|
||||||
|
|
||||||
self.value = value,
|
self.value = value
|
||||||
self.target = target,
|
self.target = target
|
||||||
self.approximate = approximate,
|
self.approximate = approximate
|
||||||
|
|
||||||
if threshold not in ("ALL", "ANY", "MAJORITY"):
|
if threshold not in ("ALL", "ANY", "MAJORITY"):
|
||||||
raise ValueError("threshold must be ALL, ANY or MAJORITY")
|
raise ValueError("threshold must be ALL, ANY or MAJORITY")
|
||||||
@ -23,12 +23,16 @@ 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
|
||||||
|
|
||||||
res_map = []
|
res_map = []
|
||||||
if self.approximate:
|
if self.approximate:
|
||||||
margin = 10
|
|
||||||
for color in collectin:
|
for color in collectin:
|
||||||
for allowed_color in self.__dict__[color_place]:
|
is_match = any(
|
||||||
res_map.append(all(abs(a - b) <= margin for a, b in zip(color, allowed_color)))
|
sum((a - b) ** 2 for a, b in zip(color, allowed_color)) <= threshold_sq
|
||||||
|
for allowed_color in self.__dict__[color_place]
|
||||||
|
)
|
||||||
|
res_map.append(is_match)
|
||||||
else:
|
else:
|
||||||
res_map = list(map(lambda x: x in self.__dict__[color_place]))
|
res_map = list(map(lambda x: x in self.__dict__[color_place]))
|
||||||
|
|
||||||
@ -44,9 +48,9 @@ class RowColorToCalue:
|
|||||||
def execute_on_row(self, row: dict[str, str], source_coll: str|None = None):
|
def execute_on_row(self, row: dict[str, str], source_coll: str|None = None):
|
||||||
color_pace_results = []
|
color_pace_results = []
|
||||||
for color_place in ["fg_color", "bg_color"]:
|
for color_place in ["fg_color", "bg_color"]:
|
||||||
color_collection = (map(lambda c: c.__dict__[color_place], row.values()))
|
color_collection = (map(lambda c: c.__dict__[color_place], filter(lambda x: x.value, row.values())))
|
||||||
color_pace_results.append(self._check_if_collection_matchers(color_collection, color_place))
|
color_pace_results.append(self._check_if_collection_matchers(color_collection, color_place))
|
||||||
|
|
||||||
if all(color_pace_results):
|
if any(color_pace_results):
|
||||||
return {self.target: self.value}
|
return {self.target: self.value}
|
||||||
return {}
|
return {}
|
||||||
@ -63,7 +63,7 @@ class TableSerializer:
|
|||||||
for expected_col, ws_idx in map_expected_with_ws.items():
|
for expected_col, ws_idx in map_expected_with_ws.items():
|
||||||
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.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")
|
fg_color=hex_to_rgb(cell.font.color.rgb if cell.font and cell.font.color else "#0")
|
||||||
)
|
)
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user