Skip to content

Commit 002c020

Browse files
committed
Convert script to python3 and pep8 it
1 parent b47eb87 commit 002c020

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

scripts/mkuidefaults.py

100644100755
Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
23

34
"""
@@ -39,7 +40,7 @@ def chunks(l, n):
3940
QCoreApplication.setApplicationName("QGIS3")
4041

4142
if len(sys.argv) == 1:
42-
print "Usage: python ./scripts/mkuidefaults.py \"location_to_ini\""
43+
print("Usage: ./scripts/mkuidefaults.py \"location_to_ini\"")
4344
sys.exit(1)
4445

4546
s = QSettings(sys.argv[1], QSettings.IniFormat)
@@ -49,33 +50,40 @@ def chunks(l, n):
4950

5051
f = open("src/app/ui_defaults.h", "w")
5152

52-
f.write("#ifndef UI_DEFAULTS_H\n#define UI_DEFAULTS_H\n\nstatic const unsigned char defaultUIgeometry[] =\n{\n")
53+
f.write("#ifndef UI_DEFAULTS_H\n#define UI_DEFAULTS_H\n" +
54+
"\nstatic const unsigned char defaultUIgeometry[] =\n{\n")
5355

5456
for chunk in chunks(ba, 16):
55-
f.write(' {},\n'.format(', '.join(map(hex, struct.unpack('B' * len(chunk), chunk)))))
57+
f.write(' {},\n'.format(
58+
', '.join(map(hex, struct.unpack('B' * len(chunk), chunk)))))
5659

5760
f.write("};\n\nstatic const unsigned char defaultUIstate[] =\n{\n")
5861

5962
ba = bytes(s.value("/UI/state"))
6063

6164
for chunk in chunks(ba, 16):
62-
f.write(' {},\n'.format(', '.join(map(hex, struct.unpack('B' * len(chunk), chunk)))))
65+
f.write(' {},\n'.format(
66+
', '.join(map(hex, struct.unpack('B' * len(chunk), chunk)))))
6367

6468
try:
6569
ba = bytes(s.value("/app/LayoutDesigner/geometry"))
66-
f.write("};\n\nstatic const unsigned char defaultLayerDesignerUIgeometry[] =\n{\n")
70+
f.write("};\n\nstatic const unsigned char " +
71+
"defaultLayerDesignerUIgeometry[] =\n{\n")
6772

6873
for chunk in chunks(ba, 16):
69-
f.write(' {},\n'.format(', '.join(map(hex, struct.unpack('B' * len(chunk), chunk)))))
74+
f.write(' {},\n'.format(
75+
', '.join(map(hex, struct.unpack('B' * len(chunk), chunk)))))
7076
except TypeError as ex:
7177
pass
7278

7379
try:
7480
ba = bytes(s.value("/app/LayoutDesigner/state"))
75-
f.write("};\n\nstatic const unsigned char defaultLayerDesignerUIstate[] =\n{\n")
81+
f.write("};\n\nstatic const unsigned char " +
82+
"defaultLayerDesignerUIstate[] =\n{\n")
7683

7784
for chunk in chunks(ba, 16):
78-
f.write(' {},\n'.format(', '.join(map(hex, struct.unpack('B' * len(chunk), chunk)))))
85+
f.write(' {},\n'.format(
86+
', '.join(map(hex, struct.unpack('B' * len(chunk), chunk)))))
7987
except TypeError as ex:
8088
pass
8189

0 commit comments

Comments
 (0)