Compare commits
2 Commits
1e833ebc7f
...
7a7479314d
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a7479314d | |||
| 067afb1515 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
.venv
|
.venv
|
||||||
|
/**/*.pyc
|
||||||
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@ -8,7 +8,7 @@
|
|||||||
"name": "Rings",
|
"name": "Rings",
|
||||||
"type": "debugpy",
|
"type": "debugpy",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/__init__.py",
|
"module": "fledermaus_formatter",
|
||||||
"args": ["-i", "data/ringe_short.xlsx", "-o", "ringe_short_out.xlsx", "-t", "ring"],
|
"args": ["-i", "data/ringe_short.xlsx", "-o", "ringe_short_out.xlsx", "-t", "ring"],
|
||||||
"console": "integratedTerminal"
|
"console": "integratedTerminal"
|
||||||
},
|
},
|
||||||
@ -16,7 +16,7 @@
|
|||||||
"name": "Countings",
|
"name": "Countings",
|
||||||
"type": "debugpy",
|
"type": "debugpy",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/__init__.py",
|
"module": "fledermaus_formatter",
|
||||||
"args": ["-i", "data/zählungen_short.xlsx", "-o", "zählungen_short_out.xlsx", "-t", "counting"],
|
"args": ["-i", "data/zählungen_short.xlsx", "-o", "zählungen_short_out.xlsx", "-t", "counting"],
|
||||||
"console": "integratedTerminal"
|
"console": "integratedTerminal"
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
4
fledermaus_formatter/__main__.py
Normal file
4
fledermaus_formatter/__main__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
from fledermaus_formatter.main import main
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@ -38,7 +38,7 @@ SPICIES = {
|
|||||||
"P.pip.",
|
"P.pip.",
|
||||||
"P.pip",
|
"P.pip",
|
||||||
"PPIP",
|
"PPIP",
|
||||||
"P.p."
|
"P.p.",
|
||||||
"ppip",
|
"ppip",
|
||||||
"Pipistrellus pipistrellus",
|
"Pipistrellus pipistrellus",
|
||||||
],
|
],
|
||||||
@ -180,7 +180,7 @@ SPICIES = {
|
|||||||
"unbekannt",
|
"unbekannt",
|
||||||
"unb.",
|
"unb.",
|
||||||
"Unbestimmt",
|
"Unbestimmt",
|
||||||
"Mspecbech"
|
"Mspecbech",
|
||||||
],
|
],
|
||||||
"Malc": [
|
"Malc": [
|
||||||
"M.alc.",
|
"M.alc.",
|
||||||
@ -256,7 +256,7 @@ SPICIES = {
|
|||||||
"MMYO",
|
"MMYO",
|
||||||
"mmyo",
|
"mmyo",
|
||||||
"Myotis Myotis",
|
"Myotis Myotis",
|
||||||
"Mspec.bech"
|
"Mspec.bech",
|
||||||
"M.m.",
|
"M.m.",
|
||||||
"M.m",
|
"M.m",
|
||||||
"MM",
|
"MM",
|
||||||
@ -310,18 +310,18 @@ CATCHED_BY = [
|
|||||||
AGE = {
|
AGE = {
|
||||||
"j": [
|
"j": [
|
||||||
"j",
|
"j",
|
||||||
"juv"
|
"juv",
|
||||||
],
|
],
|
||||||
"sub": [
|
"sub": [
|
||||||
"sub",
|
"sub",
|
||||||
"subad",
|
"subad",
|
||||||
"sub ad"
|
"sub ad",
|
||||||
"sub adult",
|
"sub adult",
|
||||||
"sub-adult"
|
"sub-adult",
|
||||||
],
|
],
|
||||||
"a": [
|
"a": [
|
||||||
"a",
|
"a",
|
||||||
"ad"
|
"ad",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,15 +329,15 @@ REPRODUCTION = {
|
|||||||
"p": [
|
"p": [
|
||||||
"plak",
|
"plak",
|
||||||
"pl",
|
"pl",
|
||||||
"p"
|
"p",
|
||||||
],
|
],
|
||||||
"g": [
|
"g": [
|
||||||
"g"
|
"g",
|
||||||
],
|
],
|
||||||
"z": [
|
"z": [
|
||||||
"lak",
|
"lak",
|
||||||
"l",
|
"l",
|
||||||
"z"
|
"z",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,12 +24,10 @@ COL_INSTRUCTIONS = {
|
|||||||
{
|
{
|
||||||
"command": "FIND_AND_REPLACE",
|
"command": "FIND_AND_REPLACE",
|
||||||
"map": REPRODUCTION,
|
"map": REPRODUCTION,
|
||||||
"reqire_full_match": True
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "FIND_AND_REPLACE",
|
"command": "FIND_AND_REPLACE",
|
||||||
"map": AGE,
|
"map": AGE,
|
||||||
"reqire_full_match": True
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "REGEX_MOVE_TO_COL",
|
"command": "REGEX_MOVE_TO_COL",
|
||||||
@ -58,7 +56,8 @@ COL_INSTRUCTIONS = {
|
|||||||
},
|
},
|
||||||
("Art",): {
|
("Art",): {
|
||||||
"command": "FIND_AND_REPLACE",
|
"command": "FIND_AND_REPLACE",
|
||||||
"map": SPICIES
|
"map": SPICIES,
|
||||||
|
"reqire_full_match": True
|
||||||
},
|
},
|
||||||
("Ort",): {
|
("Ort",): {
|
||||||
"command": "REGEX_MOVE_TO_COL",
|
"command": "REGEX_MOVE_TO_COL",
|
||||||
@ -1,10 +1,10 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
from logger import logger
|
from fledermaus_formatter.logger import logger
|
||||||
|
|
||||||
from table_handler.serializer import TableSerializer
|
from fledermaus_formatter.table_handler.serializer import TableSerializer
|
||||||
import instructions.countings_formater as countings_formater
|
import fledermaus_formatter.instructions.countings_formater as countings_formater
|
||||||
import instructions.ring_formater as ring_formater
|
import fledermaus_formatter.instructions.ring_formater as ring_formater
|
||||||
|
|
||||||
from concurrent.futures import ProcessPoolExecutor, as_completed
|
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")
|
parser.error("You must provide either input/output files or input-dir/output-dir")
|
||||||
|
|
||||||
logger.info("Done")
|
logger.info("Done")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@ -9,11 +9,11 @@ class FindAndReplace:
|
|||||||
def execute_on_cell(self, entry) -> str:
|
def execute_on_cell(self, entry) -> str:
|
||||||
res = deepcopy(entry.value)
|
res = deepcopy(entry.value)
|
||||||
|
|
||||||
for species, alternatives in self.map.items():
|
for correct_name, bad_names in self.map.items():
|
||||||
for old_version in alternatives:
|
for bad_name in bad_names:
|
||||||
if self.require_full_match and old_version == res:
|
if self.require_full_match and bad_name == res:
|
||||||
# Todo remove random leading/trailing spaces before if
|
# Todo remove random leading/trailing spaces before if
|
||||||
res = species
|
res = correct_name
|
||||||
elif not self.require_full_match:
|
elif not self.require_full_match:
|
||||||
res = res.replace(old_version, species)
|
res = res.replace(bad_name, correct_name)
|
||||||
return res
|
return res
|
||||||
@ -3,7 +3,7 @@ from openpyxl import Workbook, load_workbook
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pprint import pprint as print
|
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.find_and_replace import FindAndReplace
|
||||||
from .commands.regex_edit_col import RegexEditCol
|
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.copy import Copy
|
||||||
from .commands.regex_group_valuebased_choose import RegexGroupValuebasedChoose
|
from .commands.regex_group_valuebased_choose import RegexGroupValuebasedChoose
|
||||||
from .commands.row_color_to_value import RowColorToCalue
|
from .commands.row_color_to_value import RowColorToCalue
|
||||||
from logger import logger
|
from fledermaus_formatter.logger import logger
|
||||||
|
|
||||||
from .conditions.regex_cell import RegexCellCondition
|
from .conditions.regex_cell import RegexCellCondition
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ringe_short_out.xlsx
Normal file
BIN
ringe_short_out.xlsx
Normal file
Binary file not shown.
23
run.sh
23
run.sh
@ -2,25 +2,6 @@
|
|||||||
|
|
||||||
SCRIPT_DIR="$HOME/.config/fledermaus-formatter"
|
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
|
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[@]}"
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
zählungen_short_out.xlsx
Normal file
BIN
zählungen_short_out.xlsx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user