From e0322e10016725c59d90fe1e2ce0f51a605f983f Mon Sep 17 00:00:00 2001 From: Anders Lorentsen Date: Mon, 27 Jan 2025 09:04:01 +0100 Subject: [PATCH] import registyr repath-script to this repo, with added comment --- repath.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 repath.py diff --git a/repath.py b/repath.py new file mode 100644 index 0000000..caec700 --- /dev/null +++ b/repath.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +""" +Small script to change the pointed-to-data paths inside the regsitry files +to match the new setup on gtweb-02. Inside the container image, the CWB files +are mounted as /corpora/registry/ and /corpora/data/ + +The script may need adjusting for the various places it is run. The paths are +different on local machines, as opposed to servers. +""" + +# the lines we want to change are like this: +# HOME /corpora/gt_cwb/data/xxx_category_yyyymmdd + +import re +from pathlib import Path + +cwd = Path(".").resolve() + +for path in Path("registry").iterdir(): + contents = path.read_text() + name = path.name + contents = re.sub("HOME .*", f"HOME /corpora/data/{name}", contents) + contents = re.sub("INFO .*", f"INFO /corpora/data/{name}/.info", contents) + path.write_text(contents) + +print("done")