-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-interface-pyside.py
More file actions
executable file
·154 lines (109 loc) · 3.62 KB
/
update-interface-pyside.py
File metadata and controls
executable file
·154 lines (109 loc) · 3.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Puzzlebox - Jigsaw - Script - Update Interface Pyside
#
# Copyright Puzzlebox Productions, LLC (2011)
__changelog__ = """\
Last Update: 2011.12.25
"""
import sys
#####################################################################
# Globals
#####################################################################
DEFAULT_INPUT_FILE = 'Puzzlebox/Jigsaw/Design_Interface.py'
DEFAULT_OUTPUT_FILE = 'Puzzlebox/Jigsaw/Design_Interface.py'
REPLACE_STRINGS = { \
'from PyQt4 import QtCore, QtGui\n': \
"""
import Configuration as configuration
if configuration.ENABLE_PYSIDE:
try:
#import PySide as PyQt4
from PySide import QtCore, QtGui, QtNetwork, QtWebKit
except Exception, e:
print "ERROR: Exception importing PySide:",
print e
configuration.ENABLE_PYSIDE = False
else:
print "INFO: [Jigsaw:__MODULE_NAME__] Using PySide module"
if not configuration.ENABLE_PYSIDE:
print "INFO: [Jigsaw:__MODULE_NAME__] Using PyQt4 module"
from PyQt4 import QtCore, QtGui, QtNetwork, QtWebKit
#try:
#from PySide import QtCore, QtGui, QtWebKit
#except:
#from PyQt4 import QtCore, QtGui, QtWebKit
""", \
'from PyQt4 import QtWebKit\n': \
'#from PyQt4 import QtWebKit\n', \
' self.gridLayout_2.setMargin(0)\n': \
'# self.gridLayout_2.setMargin(0)\n', \
' self.verticalLayout.setMargin(10)\n': \
'# self.verticalLayout.setMargin(10)\n', \
' self.verticalLayoutSessionProfile_2.setMargin(0)\n': \
'# self.verticalLayoutSessionProfile_2.setMargin(0)\n', \
# Plug-in Web
' Form.setObjectName(_fromUtf8("Form"))\n': \
' #Form.setObjectName(_fromUtf8("Form"))\n', \
' Form.resize(400, 300)\n': \
' #Form.resize(400, 300)\n', \
#' Form.setSizePolicy(sizePolicy)\n': \
#' #Form.setSizePolicy(sizePolicy)\n', \
' self.verticalLayoutWidget = QtGui.QWidget(Form)\n': \
""" #self.verticalLayoutWidget = QtGui.QWidget(Form)
self.verticalLayoutWidget = QtGui.QWidget()
""", \
' self.verticalLayout.setMargin(0)\n': \
' #self.verticalLayout.setMargin(0)\n', \
# Plug-in Brain Blender
' Form.resize(752, 660)\n': \
' #Form.resize(752, 660)\n', \
' self.horizontalLayoutWidget = QtGui.QWidget(Form)\n': \
""" #self.horizontalLayoutWidget = QtGui.QWidget(Form)
self.horizontalLayoutWidget = QtGui.QWidget()
""", \
' self.horizontalLayout.setMargin(0)\n': \
' #self.horizontalLayout.setMargin(0)\n', \
}
#####################################################################
# Functions
#####################################################################
def remove_form_resize(line):
if 'Form.resize' in line:
return('#Form.resize()\n')
else:
return(line)
#####################################################################
def replace_line(line):
if line in REPLACE_STRINGS.keys():
return(REPLACE_STRINGS[line])
else:
return(line)
#####################################################################
# Main
#####################################################################
if __name__ == '__main__':
try:
inputFile = sys.argv[1]
outputFile = sys.argv[2]
except:
inputFile = DEFAULT_INPUT_FILE
outputFile = DEFAULT_OUTPUT_FILE
module_name = outputFile.split('/')[-1]
module_name = module_name.replace('.py', '')
data = ''
input = open(inputFile, 'r')
for line in input.readlines():
line = remove_form_resize(line)
line = replace_line(line)
#if line in REPLACE_STRINGS.keys():
#data = data + REPLACE_STRINGS[line]
#else:
#data = data + line
data = data + line
input.close()
data = data.replace('__MODULE_NAME__', module_name)
output = open(outputFile, 'w')
output.write(data)
output.close()