2026-04-02 13:35:41 +02:00

70 lines
1.6 KiB
Python

from .mappings import *
from copy import deepcopy
EXPECTED_INPUT_TABLE_SCHEMA = [
"Anzahl",
"Art",
"Geschlecht",
"Datum",
"Ort",
"Davon m",
"Davon w",
"Fangart",
"Bemerkung"
]
EXPECTED_OUTPUT_TABLE_SCHEMA = deepcopy(EXPECTED_INPUT_TABLE_SCHEMA)
EXPECTED_OUTPUT_TABLE_SCHEMA.remove("Geschlecht")
COL_INSTRUCTIONS = {
("Art",): {
"command": "FIND_AND_REPLACE",
"map": SPICIES,
"reqire_full_match": True
},
("Ort",): [
{
"command": "FIND_AND_REPLACE",
"map": CATCHED_BY
},
{
"command": "REGEX_MOVE_TO_COL",
"with_input_iteration": list(CATCHED_BY.keys()), # Moves matching group {{% 1 %}} to "to"
"match": r"^.*({{% 0 %}}),?(?:.*+)*$",
"to": "Fangart",
"copy": True
}
],
("Anzahl",): [{
"command": "REGEX_EDIT_COL",
"match": r"^ *$",
"replace_with": "1",
"match_none": True
},
{
"command": "REGEX_GROUP_VALUEBASED_CHOOS",
"match": r"^ *([0-9]+) *oder *([0-9]+) *$",
"highest": True
}],
}
ROW_INSTRUCTION = [
{
"command": "CONDITIONAL_COPY",
"when_regex": {
"Geschlecht": r"^.*(m),?(?:.*+)*$",
"Anzahl": r"([0-9]+)"
},
"source": "Anzahl",
"target": "Davon m"
},
{
"command": "CONDITIONAL_COPY",
"when_regex": {
"Geschlecht": r"^.*(w),?(?:.*+)*$",
"Anzahl": r"([0-9]+)"
},
"source": "Anzahl",
"target": "Davon w"
},
]