fixing things
This commit is contained in:
parent
cf4010c015
commit
ce4efded12
@ -31,7 +31,8 @@ COL_INSTRUCTIONS = {
|
||||
"command": "REGEX_MOVE_TO_COL",
|
||||
"with_input_iteration": list(CATCHED_BY.keys()), # Moves matching group {{% 1 %}} to "to"
|
||||
"match": r"^.*({{% 0 %}}),?(?:.*+)*$",
|
||||
"to": "Fangart"
|
||||
"to": "Fangart",
|
||||
"copy": True
|
||||
}
|
||||
],
|
||||
("Anzahl",): [{
|
||||
|
||||
@ -316,6 +316,7 @@ CATCHED_BY = {
|
||||
"Nfg": [*add_cased_options("nfg"),
|
||||
*add_cased_options("nf")],
|
||||
"KK": [*add_cased_options("kk"),
|
||||
*add_cased_options(" k "),
|
||||
*add_cased_options("überwinterungskästen"),
|
||||
*add_cased_options("kastenkontrolle"),
|
||||
*add_cased_options("kasten")],
|
||||
|
||||
@ -59,7 +59,7 @@ def main():
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.v:
|
||||
print("1.4")
|
||||
print("1.5")
|
||||
return
|
||||
if not args.type:
|
||||
parser.error("The --type argument is required.")
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import re
|
||||
from fledermaus_formatter.table_handler.Entry import Entry
|
||||
from copy import deepcopy
|
||||
|
||||
@ -13,7 +12,6 @@ class FindAndReplace:
|
||||
for correct_name, bad_names in self.map.items():
|
||||
for bad_name in bad_names:
|
||||
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:
|
||||
|
||||
@ -3,9 +3,10 @@ import re
|
||||
from fledermaus_formatter.table_handler.Entry import Entry
|
||||
|
||||
class RegexMoveToCol:
|
||||
def __init__(self, match: str, to: str, with_input_iteration: list[list[str]]|None = None):
|
||||
def __init__(self, match: str, to: str, with_input_iteration: list[list[str]]|None = None, copy: bool = False):
|
||||
self.match = match
|
||||
self.to = to
|
||||
self.copy = copy
|
||||
|
||||
if with_input_iteration is not None:
|
||||
with_input_iteration = (
|
||||
@ -65,13 +66,16 @@ class RegexMoveToCol:
|
||||
def execute_on_row(self, row: dict[str, str], source_coll: str = None):
|
||||
if not source_coll:
|
||||
raise ValueError("source_col required")
|
||||
changes = {}
|
||||
|
||||
if self.with_input_iteration:
|
||||
changes = {}
|
||||
for iteration in self.with_input_iteration:
|
||||
used_regex = self.match
|
||||
for operation_id in range(0, self.__operation_input_depth):
|
||||
used_regex = used_regex.replace(f"{{{{% {operation_id} %}}}}", iteration[operation_id])
|
||||
changes = self.do_changes(source_coll, used_regex, row, changes)
|
||||
return changes
|
||||
else:
|
||||
return self.do_changes(source_coll, self.match, row)
|
||||
changes = self.do_changes(source_coll, self.match, row)
|
||||
if self.copy and source_coll in changes:
|
||||
del changes[source_coll]
|
||||
return changes
|
||||
@ -32,7 +32,7 @@ class RowColorToCalue:
|
||||
|
||||
|
||||
def _check_if_collection_matchers(self, collectin: dict[tuple[int, int, int]], color_place: str) -> bool:
|
||||
threshold_sq = 120
|
||||
threshold_sq = 80
|
||||
|
||||
res_map = []
|
||||
if self.approximate:
|
||||
|
||||
@ -105,7 +105,7 @@ class TableSerializer:
|
||||
case "FIND_AND_REPLACE":
|
||||
res = FindAndReplace(instruct["map"], instruct.get("reqire_full_match", False)).execute_on_cell(in_place_working_row[source_cell])
|
||||
case "REGEX_MOVE_TO_COL":
|
||||
res_row = RegexMoveToCol(instruct["match"], instruct["to"], instruct.get("with_input_iteration")) \
|
||||
res_row = RegexMoveToCol(instruct["match"], instruct["to"], instruct.get("with_input_iteration"), instruct.get("copy", False)) \
|
||||
.execute_on_row(in_place_working_row, source_cell)
|
||||
case "REGEX_EDIT_COL":
|
||||
res = RegexEditCol(instruct["match"], instruct["replace_with"], instruct.get("matching_group_rearange"), instruct.get("match_none"))\
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user