Refactor code structure for improved readability and maintainability
This commit is contained in:
24
dev/compile_modified.py
Normal file
24
dev/compile_modified.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import py_compile
|
||||
import sys
|
||||
paths = [
|
||||
'src/ui/widgets/new_edition_check.py',
|
||||
'src/utils/icon.py',
|
||||
'src/ui/widgets/graph.py',
|
||||
'src/ui/userInterface.py',
|
||||
'src/ui/dialogs/mailTemplate.py',
|
||||
'src/services/catalogue.py',
|
||||
'src/backend/catalogue.py',
|
||||
'src/parsers/xml_parser.py',
|
||||
'src/parsers/csv_parser.py',
|
||||
'src/parsers/transformers/transformers.py',
|
||||
'src/core/semester.py',
|
||||
]
|
||||
errs = 0
|
||||
for p in paths:
|
||||
try:
|
||||
py_compile.compile(p, doraise=True)
|
||||
print('OK:', p)
|
||||
except Exception as e:
|
||||
print('ERROR:', p, e)
|
||||
errs += 1
|
||||
sys.exit(errs)
|
||||
35
dev/update_translations.ps1
Normal file
35
dev/update_translations.ps1
Normal file
@@ -0,0 +1,35 @@
|
||||
# Requires PowerShell 5+
|
||||
# Scans all .ui files under src/ and runs pyside6-lupdate to generate/update .ts files next to them.
|
||||
# Usage: Run from repository root: `pwsh dev/update_translations.ps1` or `powershell -ExecutionPolicy Bypass -File dev/update_translations.ps1`
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# Use current working directory (CWD) for relative paths
|
||||
$cwd = Get-Location
|
||||
$lupdate = Join-Path $cwd '.venv\Scripts\pyside6-lupdate.exe'
|
||||
if (-not (Test-Path $lupdate)) {
|
||||
Write-Error "Qt for Python lupdate not found at '$lupdate'. Ensure venv is created and PySide6 tools installed."
|
||||
}
|
||||
|
||||
$uiFiles = Get-ChildItem -Path (Join-Path $cwd 'src') -Filter '*.ui' -Recurse -File
|
||||
if ($uiFiles.Count -eq 0) {
|
||||
Write-Host 'No .ui files found under src/. Nothing to update.'
|
||||
exit 0
|
||||
}
|
||||
|
||||
foreach ($ui in $uiFiles) {
|
||||
# Compute .ts path next to the .ui file
|
||||
$tsPath = [System.IO.Path]::ChangeExtension($ui.FullName, '.ts')
|
||||
# Ensure target directory exists
|
||||
$tsDir = Split-Path -Parent $tsPath
|
||||
if (-not (Test-Path $tsDir)) { New-Item -ItemType Directory -Path $tsDir | Out-Null }
|
||||
|
||||
# Use absolute paths to avoid path resolution issues
|
||||
$uiAbs = $ui.FullName
|
||||
$tsAbs = $tsPath
|
||||
|
||||
Write-Host "Updating translations: $uiAbs -> $tsAbs"
|
||||
& $lupdate $uiAbs '-ts' $tsAbs
|
||||
}
|
||||
|
||||
Write-Host 'Translation update completed.'
|
||||
31
dev/update_translations.sh
Normal file
31
dev/update_translations.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# Scans all .ui files under src/ and runs pyside6-lupdate to generate/update .ts files next to them.
|
||||
# Usage: Run from repository root: `bash dev/update_translations.sh`
|
||||
set -euo pipefail
|
||||
|
||||
# Ensure we are in repo root (script's directory is dev/)
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
LUPDATE=".venv/bin/pyside6-lupdate"
|
||||
if [[ ! -x "$LUPDATE" ]]; then
|
||||
echo "Qt for Python lupdate not found at '$LUPDATE'. Ensure venv is created and PySide6 tools installed." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
shopt -s nullglob
|
||||
mapfile -t UI_FILES < <(find src -type f -name '*.ui')
|
||||
|
||||
if [[ ${#UI_FILES[@]} -eq 0 ]]; then
|
||||
echo "No .ui files found under src/. Nothing to update."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for ui in "${UI_FILES[@]}"; do
|
||||
ts="${ui%.ui}.ts"
|
||||
echo "Updating translations: $ui -> $ts"
|
||||
"$LUPDATE" "$ui" -ts "$ts"
|
||||
done
|
||||
|
||||
echo "Translation update completed."
|
||||
Reference in New Issue
Block a user