Philipp Hörist pushed to branch master at gajim / gajim


Commits:
a308fa83 by lovetox at 2021-12-26T22:32:27+01:00
Scripts: Simplify UI type generation

- - - - -


1 changed file:

- scripts/dev/generate_ui_types.py


Changes:

=====================================
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('~'):



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/a308fa83765232b8078a3a41bebaf1d81cad5105

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/a308fa83765232b8078a3a41bebaf1d81cad5105
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to