forked from metabrainz/picard-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_ui.py
executable file
·34 lines (24 loc) · 893 Bytes
/
build_ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
import glob
import os
from PyQt5 import uic
os.chdir(os.path.dirname(__file__))
plugin_dir = os.path.relpath('plugins')
def compile_ui(uifile, pyfile):
if newer(uifile, pyfile):
print("compiling %s -> %s" % (uifile, pyfile))
with open(pyfile, "w") as out:
uic.compileUi(uifile, out)
else:
print("skipping %s -> %s: up to date" % (uifile, pyfile))
def newer(file1, file2):
"""Returns True, if file1 has been modified after file2
"""
if not os.path.exists(file2):
return True
return os.path.getmtime(file1) > os.path.getmtime(file2)
if __name__ == '__main__':
for uifile in glob.glob(os.path.join(plugin_dir, '*/*.ui')):
pyfile = os.path.splitext(os.path.basename(uifile))[0] + '.py'
pyfile = os.path.join(os.path.dirname(uifile), pyfile)
compile_ui(uifile, pyfile)