Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2022-12-04 02:41:11 +0300
committerPhilipp Hörist <philipp@hoerist.com>2022-12-04 02:41:11 +0300
commit3d5363d060ddb5fbf9814e9bed4800f0dfee8a7e (patch)
tree69f5c576b982ed5ee477d71e53bd95dbff587a29 /scripts
parent2bbcd18bbe9609d8155c5988076aa4004b69e6cb (diff)
refactor: Scripts: Fix various issues
- Use logging module everywhere - Fix boolean traps - replace exit() with sys.exit()
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/bump_version.py5
-rwxr-xr-xscripts/generate_ui_types.py16
-rwxr-xr-xscripts/update_translations.py2
3 files changed, 15 insertions, 8 deletions
diff --git a/scripts/bump_version.py b/scripts/bump_version.py
index 84ea3fae8..4c99ece13 100755
--- a/scripts/bump_version.py
+++ b/scripts/bump_version.py
@@ -1,10 +1,11 @@
#!/usr/bin/env python3
-import re
import argparse
from datetime import datetime
from pathlib import Path
+import re
import subprocess
+import sys
REPO_DIR = Path(__file__).resolve().parent.parent
@@ -23,7 +24,7 @@ def get_current_version() -> str:
match = re.search(VERSION_RX, content)
if match is None:
- exit('Unable to find current version')
+ sys.exit('Unable to find current version')
return match[0]
diff --git a/scripts/generate_ui_types.py b/scripts/generate_ui_types.py
index 1a4d75aba..260e61f6f 100755
--- a/scripts/generate_ui_types.py
+++ b/scripts/generate_ui_types.py
@@ -3,15 +3,21 @@
# Reads all .ui files and creates builder.pyi
# Excecute this script from the repo root dir
+import logging
+import sys
from io import TextIOWrapper
from pathlib import Path
-from xml.etree import ElementTree as ET
+from xml.etree import ElementTree
+logging.basicConfig(level='INFO', format='%(levelname)s: %(message)s')
+log = logging.getLogger()
+
cwd = Path.cwd()
if cwd.name != 'gajim':
- exit('Script needs to be excecuted from gajim repository root directory')
+ sys.exit('Script needs to be excecuted from gajim repository '
+ 'root directory')
in_path = cwd / 'gajim' / 'data' / 'gui'
out_path = cwd / 'gajim' / 'gtk' / 'builder.pyi'
@@ -45,14 +51,14 @@ def get_builder(file_name: str, widgets: list[str] = ...) -> Builder: ...'''
def make_class_name(path: Path) -> str:
name = path.name.removesuffix('.ui')
names = name.split('_')
- names = map(lambda x: x.capitalize(), names)
+ names = [name.capitalize() for name in names]
return ''.join(names) + 'Builder'
def parse(path: Path, file: TextIOWrapper) -> str:
- print('read', path)
+ log.info('Read %s', path)
lines: list[str] = []
- tree = ET.parse(path)
+ tree = ElementTree.parse(path)
for node in tree.iter(tag='object'):
id_ = node.attrib.get('id')
if id_ is None:
diff --git a/scripts/update_translations.py b/scripts/update_translations.py
index 3f867a315..c5e66ac46 100755
--- a/scripts/update_translations.py
+++ b/scripts/update_translations.py
@@ -23,7 +23,7 @@ TRANSLATABLE_FILES = [
def template_is_equal(old_template_path: Path, new_template: str) -> bool:
- with open(old_template_path, 'r', encoding='utf8') as f:
+ with open(old_template_path, encoding='utf8') as f:
old_template = f.read()
pattern = r'"POT-Creation-Date: .*\n"'