diff options
author | lovetox <philipp@hoerist.com> | 2021-12-27 00:29:43 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2021-12-27 00:32:27 +0300 |
commit | a308fa83765232b8078a3a41bebaf1d81cad5105 (patch) | |
tree | a40083438faefbce34ef683ad084bc41c77c50ca /scripts | |
parent | 84ef2245ee0578750e31fdd1001c877bb128253d (diff) |
Scripts: Simplify UI type generation
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/dev/generate_ui_types.py | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/scripts/dev/generate_ui_types.py b/scripts/dev/generate_ui_types.py index 1b1cd2b0e..7b82925fa 100755 --- a/scripts/dev/generate_ui_types.py +++ b/scripts/dev/generate_ui_types.py @@ -1,28 +1,21 @@ #!/usr/bin/env python3 -import sys -from pathlib import Path +# Reads all .ui files and creates builder.pyi +# Excecute this script from the repo root dir +from pathlib import Path from xml.etree import ElementTree as ET -try: - path = sys.argv[1] -except Exception: - print('path to file/folder missing') - exit() - -path = Path(path) -if path.is_dir(): - paths = list(path.iterdir()) +cwd = Path.cwd() -elif path.is_file(): - paths = [path] +if cwd.name != 'gajim': + exit('Script needs to be excecuted from gajim repository root directory') -else: - print('Path must be folder or file:', path) - exit() +in_path = cwd / 'gajim' / 'data' / 'gui' +out_path = cwd / 'gajim' / 'gtk' / 'builder.pyi' +paths = list(in_path.iterdir()) IMPORTS = ''' from typing import Literal @@ -86,8 +79,7 @@ def parse(path, file): builder_names = [] -current_dir = Path('./builder.pyi') -with current_dir.open(mode='w') as file: +with out_path.open(mode='w') as file: file.write(IMPORTS) for path in paths: if path.name.endswith('~'): |