fledermaus/instructions/ring_formater.py
2026-02-15 22:35:25 +01:00

83 lines
2.1 KiB
Python

from mappings import *
EXPECTED_INPUT_TABLE_SCHEMA = [
"Ringnummer",
"Art",
"Geschlecht"
"Alter",
"Reproduktionsstatus",
"Unterarmlänge",
"Gewicht",
"Datum",
"Ort",
"Fangart",
"Uhrzeit",
"Proben",
"Wiederfunde",
"Bemerkung"
]
EXPECTED_OUTPUT_TABLE_SCHEMA = EXPECTED_INPUT_TABLE_SCHEMA
COL_INSTRUCTIONS = {
["Geschlecht"]: {
"command": {
"name": "REGEX_MOVE_TO_COL",
"with_input_iteration": flatten_dict(REPRODUCTION), # Moves matching group {{% 1 %}} to "to"
"match": r"^(?:[^ ]* +)*({{% 1 %}}),?(?: .*+)*$",
"to": "Reproduktionsstatus"
}
},
["Geschlecht"]: {
"command": {
"name": "REGEX_MOVE_TO_COL",
"with_input_iteration": flatten_dict(AGE), # Moves matching group {{% 1 %}} to "to"
"match": r"^(?:[^ ]* +)*({{% 1 %}}),?(?: .*+)*$",
"to": "Alter"
}
},
["Geschlecht"]: {
# Special case ma -> Geschlecht a | Alter a
"command": {
"name": "REGEX_MOVE_TO_COL",
"match": r"^(?:[^ ]* +)*m(a),?(?: .*+)*$",
"to": "Alter"
}
},
["Ringnummer"]: {
"command": {
"name": "REGEX_EDIT_COL",
"match": r"^[^a-zA-Z\d]*([a-zA-Z]*)[^a-zA-Z\d]*(\d+)$",
"to": "{{% 1 %}}{{% 2 %}}"
}
},
["Art"]: {
"command": {
"name": "FIND_AND_REPLACE",
"map": SPICIES
}
},
["Ort"]: {
"command": {
"name": "REGEX_MOVE_TO_COL",
"with_input_iteration": flatten_dict(CATCHED_BY), # Moves matching group {{% 1 %}} to "to"
"match": r"^(?:[^ ]* +)*({{% 1 %}}),?(?: .*+)*$",
"to": "Fangart"
}
}
}
ROW_INSTRUCTIONS = [
{
"command": "ROW_COLOR_TO_BOOL", # Match when found as text color in any col of the row
"color": ["#ff0000", "#0000ff"],
"approximate": True,
"column": "Wiederfunde",
"value": "TRUE"
},
{
"command": "ROW_COPY_REMAINING"
}
]