Allow languages to be updated from any directory

Now these commands will work:
python .\lang\update-po.py
python .\lang\update-pot.py

When current working directory is
.\Prusa-Firmware\

Previously, you'd need to call the
script within the lang folder.
This commit is contained in:
Guðni Már Gilbert 2022-11-26 15:14:18 +00:00
parent 53ced0cb21
commit 7966633c1a
3 changed files with 5 additions and 4 deletions

View File

@ -12,7 +12,7 @@ from pathlib import Path, PurePosixPath
FILE_LIST: list[Path] = [] FILE_LIST: list[Path] = []
# Absolute path # Absolute path
BASE_DIR: Path = Path.cwd().resolve() BASE_DIR: Path = Path.absolute(Path(__file__).parent)
PO_DIR: Path = BASE_DIR / "po" PO_DIR: Path = BASE_DIR / "po"
# Pathlib can't change the working directory yet # Pathlib can't change the working directory yet

View File

@ -12,7 +12,7 @@ from pathlib import Path
import polib import polib
from polib import POFile from polib import POFile
BASE_DIR: Path = Path.cwd() BASE_DIR: Path = Path.absolute(Path(__file__).parent)
PO_DIR: Path = BASE_DIR / "po" PO_DIR: Path = BASE_DIR / "po"
PO_FILE_LIST: list[Path] = [] PO_FILE_LIST: list[Path] = []
POT_REFERENCE: POFile = polib.pofile(PO_DIR/'Firmware.pot') POT_REFERENCE: POFile = polib.pofile(PO_DIR/'Firmware.pot')

View File

@ -15,7 +15,7 @@ import shutil
import subprocess import subprocess
from subprocess import CalledProcessError from subprocess import CalledProcessError
BASE_DIR: Path = Path.cwd().resolve() BASE_DIR: Path = Path.absolute(Path(__file__).parent)
PROJECT_DIR: Path = BASE_DIR.parent PROJECT_DIR: Path = BASE_DIR.parent
PO_DIR: Path = BASE_DIR / "po" PO_DIR: Path = BASE_DIR / "po"
@ -45,11 +45,12 @@ def main():
print(error) print(error)
# Run the lang-extract.py script # Run the lang-extract.py script
SCRIPT_PATH = BASE_DIR.joinpath("lang-extract.py")
try: try:
subprocess.check_call( subprocess.check_call(
[ [
"python", "python",
"lang-extract.py", SCRIPT_PATH,
"--no-missing", "--no-missing",
"-s", "-s",
"-o", "-o",