Compare commits

..

2 Commits

Author SHA1 Message Date
7a7479314d fixing bad mappings 2026-03-28 12:31:58 +01:00
067afb1515 made to module 2026-03-28 12:19:58 +01:00
35 changed files with 33 additions and 52 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
.venv
.venv
/**/*.pyc

4
.vscode/launch.json vendored
View File

@ -8,7 +8,7 @@
"name": "Rings",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/__init__.py",
"module": "fledermaus_formatter",
"args": ["-i", "data/ringe_short.xlsx", "-o", "ringe_short_out.xlsx", "-t", "ring"],
"console": "integratedTerminal"
},
@ -16,7 +16,7 @@
"name": "Countings",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/__init__.py",
"module": "fledermaus_formatter",
"args": ["-i", "data/zählungen_short.xlsx", "-o", "zählungen_short_out.xlsx", "-t", "counting"],
"console": "integratedTerminal"
}

Binary file not shown.

View File

@ -0,0 +1,4 @@
from fledermaus_formatter.main import main
if __name__ == "__main__":
main()

View File

@ -38,7 +38,7 @@ SPICIES = {
"P.pip.",
"P.pip",
"PPIP",
"P.p."
"P.p.",
"ppip",
"Pipistrellus pipistrellus",
],
@ -180,7 +180,7 @@ SPICIES = {
"unbekannt",
"unb.",
"Unbestimmt",
"Mspecbech"
"Mspecbech",
],
"Malc": [
"M.alc.",
@ -256,7 +256,7 @@ SPICIES = {
"MMYO",
"mmyo",
"Myotis Myotis",
"Mspec.bech"
"Mspec.bech",
"M.m.",
"M.m",
"MM",
@ -310,18 +310,18 @@ CATCHED_BY = [
AGE = {
"j": [
"j",
"juv"
"juv",
],
"sub": [
"sub",
"subad",
"sub ad"
"sub ad",
"sub adult",
"sub-adult"
"sub-adult",
],
"a": [
"a",
"ad"
"ad",
]
}
@ -329,15 +329,15 @@ REPRODUCTION = {
"p": [
"plak",
"pl",
"p"
"p",
],
"g": [
"g"
"g",
],
"z": [
"lak",
"l",
"z"
"z",
]
}

View File

@ -24,12 +24,10 @@ COL_INSTRUCTIONS = {
{
"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",
@ -58,7 +56,8 @@ COL_INSTRUCTIONS = {
},
("Art",): {
"command": "FIND_AND_REPLACE",
"map": SPICIES
"map": SPICIES,
"reqire_full_match": True
},
("Ort",): {
"command": "REGEX_MOVE_TO_COL",

View File

@ -1,10 +1,10 @@
import argparse
import os
from logger import logger
from fledermaus_formatter.logger import logger
from table_handler.serializer import TableSerializer
import instructions.countings_formater as countings_formater
import instructions.ring_formater as ring_formater
from fledermaus_formatter.table_handler.serializer import TableSerializer
import fledermaus_formatter.instructions.countings_formater as countings_formater
import fledermaus_formatter.instructions.ring_formater as ring_formater
from concurrent.futures import ProcessPoolExecutor, as_completed
@ -97,7 +97,3 @@ def main():
parser.error("You must provide either input/output files or input-dir/output-dir")
logger.info("Done")
if __name__ == "__main__":
main()

View File

@ -9,11 +9,11 @@ class FindAndReplace:
def execute_on_cell(self, entry) -> str:
res = deepcopy(entry.value)
for species, alternatives in self.map.items():
for old_version in alternatives:
if self.require_full_match and old_version == res:
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 = species
res = correct_name
elif not self.require_full_match:
res = res.replace(old_version, species)
res = res.replace(bad_name, correct_name)
return res

View File

@ -3,7 +3,7 @@ from openpyxl import Workbook, load_workbook
from dataclasses import dataclass
from pprint import pprint as print
import instructions.mappings as mappings
import fledermaus_formatter.instructions.mappings as mappings
from .commands.find_and_replace import FindAndReplace
from .commands.regex_edit_col import RegexEditCol
@ -11,7 +11,7 @@ from .commands.regex_move_to_col import RegexMoveToCol
from .commands.copy import Copy
from .commands.regex_group_valuebased_choose import RegexGroupValuebasedChoose
from .commands.row_color_to_value import RowColorToCalue
from logger import logger
from fledermaus_formatter.logger import logger
from .conditions.regex_cell import RegexCellCondition

BIN
ringe_short_out.xlsx Normal file

Binary file not shown.

23
run.sh
View File

@ -2,25 +2,6 @@
SCRIPT_DIR="$HOME/.config/fledermaus-formatter"
to_absolute_args() {
local result=()
for arg in "$@"; do
if [ -e "$arg" ] || [ -d "$arg" ] || [ -f "$arg" ]; then
result+=("$(realpath "$arg")")
else
result+=("$arg")
fi
done
printf '%s\n' "${result[@]}"
}
ABS_ARGS=()
while IFS= read -r line; do
ABS_ARGS+=("$line")
done < <(to_absolute_args "$@")
cd $SCRIPT_DIR
source $SCRIPT_DIR/.venv/bin/activate
$SCRIPT_DIR/.venv/bin/python3 __init__.py "${ABS_ARGS[@]}"
export PYTHONPATH=$SCRIPT_DIR:$PYTHONPATH
$SCRIPT_DIR/.venv/bin/python3 -m fledermaus_formatter "${ABS_ARGS[@]}"

BIN
zählungen_short_out.xlsx Normal file

Binary file not shown.