82 lines
2.1 KiB
Python
82 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": "FIND_AND_REPLACE",
|
|
"map": REPRODUCTION,
|
|
"reqire_full_match": True
|
|
},
|
|
{
|
|
"command": "FIND_AND_REPLACE",
|
|
"map": AGE,
|
|
"reqire_full_match": True
|
|
},
|
|
{
|
|
"command": "REGEX_MOVE_TO_COL",
|
|
"with_input_iteration": list(REPRODUCTION.keys()), # Moves matching group {{% 1 %}} to "to"
|
|
"match": r"^(?:[^ ]* +)*({{% 0 %}}),?(?: .*+)*$",
|
|
"to": "Reproduktionsstatus"
|
|
},
|
|
{
|
|
"command": "REGEX_MOVE_TO_COL",
|
|
"with_input_iteration": list(AGE.keys()), # Moves matching group {{% 1 %}} to "to"
|
|
"match": r"^(?:[^ ]* +)*({{% 0 %}}),?(?: .*+)*$",
|
|
"to": "Alter"
|
|
|
|
},
|
|
{
|
|
# Special case ma -> Geschlecht a | Alter a
|
|
"command": "REGEX_MOVE_TO_COL",
|
|
"match": r"^(?:[^ ]* +)*m(a),?(?: .*+)*$",
|
|
"to": "Alter"
|
|
}],
|
|
("Ringnummer",): {
|
|
"command": "REGEX_EDIT_COL",
|
|
"matching_group_rearange": True,
|
|
"match": r"^[^a-zA-Z\d]*([a-zA-Z]*)[^a-zA-Z\d]*(\d+)$",
|
|
"replace_with": r"{{% 0 %}}{{% 1 %}}"
|
|
},
|
|
("Art",): {
|
|
"command": "FIND_AND_REPLACE",
|
|
"map": SPICIES
|
|
},
|
|
("Ort",): {
|
|
"command": "REGEX_MOVE_TO_COL",
|
|
"with_input_iteration": CATCHED_BY, # Moves matching group {{% 1 %}} to "to"
|
|
"match": r"^(?:[^ ]* +)*({{% 0 %}}),?(?: .*+)*$",
|
|
"to": "Fangart"
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ROW_INSTRUCTIONS = [
|
|
{
|
|
"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)],
|
|
"approximate": True,
|
|
"threshold": "ALL", # ALL, ANY, MAJORITY of row must be collored
|
|
"target": "Wiederfunde",
|
|
"value": "TRUE",
|
|
}
|
|
] |