forked from papyros/qml-material
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqrc.py
More file actions
executable file
·52 lines (38 loc) · 1.62 KB
/
Copy pathqrc.py
File metadata and controls
executable file
·52 lines (38 loc) · 1.62 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/env python3
# Generate a Qt Resource file from the contents of a list of directories
# qrc.py <dir1> <dir2> ...
import os
import os.path
def create_qrc(dirname, prefix=None):
basename = os.path.basename(dirname)
file_list = []
for root, dirs, files in os.walk(dirname):
file_list += [os.path.relpath(os.path.join(root, filename), dirname)
for filename in files]
file_list.sort()
contents = '<!DOCTYPE RCC>\n<RCC version="1.0">\n\n'
if prefix:
contents += '<qresource prefix="/{}">\n'.format(prefix)
else:
contents += '<qresource>\n'
for filename in file_list:
if (filename.endswith('.js') or filename.endswith('.qml') or
filename.endswith('.otf') or filename.endswith('.ttf') or
filename.endswith('.png') or filename.endswith('.jpg') or
filename.endswith('.jpeg') or filename.endswith('.svg') or
filename == 'qmldir'):
contents += '\t<file>' + filename + '</file>\n'
contents += '</qresource>\n\n</RCC>\n'
with open(os.path.join(dirname, basename + '.qrc'), 'w') as f:
f.write(contents)
if __name__ == '__main__':
create_qrc('demo')
create_qrc('src/core', 'Material')
create_qrc('src/controls', 'Material')
create_qrc('src/components', 'Material')
create_qrc('src/extras', 'Material/Extras')
create_qrc('src/listitems', 'Material/ListItems')
create_qrc('src/popups', 'Material')
create_qrc('src/styles', 'QtQuick/Controls/Styles/Material')
create_qrc('src/window', 'Material')
create_qrc('fonts', 'Material/Fonts')