-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssistant.py
More file actions
97 lines (66 loc) · 2.53 KB
/
Assistant.py
File metadata and controls
97 lines (66 loc) · 2.53 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
#/usr/env/bin python
# default modules
import os
import sys
import datetime
# qt
from PyQt4 import QtGui , uic
from PyQt4 import QtCore
# local libs
import AssistantLib
# import interface
ui_class, base_class = uic.loadUiType("ui/UIAssistant.ui")
# interface class
class Assistant(ui_class,base_class):
def __init__(self):
super(Assistant,self).__init__()
self.setupUi(self)
self.fillDefaultValues()
self.setupConnections()
def setupConnections(self):
QtCore.QObject.connect(self.BT_generate,QtCore.SIGNAL("clicked()"),self.run)
def fillDefaultValues(self):
# load the templates mapping
# sand et plugin types
pluginTypes=AssistantLib.templateMapping
for type in pluginTypes:
self.CB_pluginType.addItem(type)
# set nodeIds
defaultIds=AssistantLib.defaultNodesIds
for id in defaultIds:
self.CB_pluginId.addItem(id)
# user name
username = os.getenv("USER")
self.TX_authorName.setText(username)
# plugin name
self.TX_pluginName.setText("Change Me")
# docs
self.TX_description.setPlainText("fill it with a plugin description")
#set about page
self.WB_about.setUrl(QtCore.QUrl("about.html"))
def run(self):
datas=AssistantLib.pluginDatas
# get the plugin Type
cbId = self.CB_pluginType.currentIndex()
cbText = self.CB_pluginType.itemText(cbId)
template = AssistantLib.templateMapping[str(cbText)]
datas["$PLUGINTYPE"]=template
# get the plugin id
cbId_ = self.CB_pluginId.currentIndex()
cbText_ = self.CB_pluginId.itemText(cbId_)
datas["$NODEID"]=str(cbText_)
# get the plugin Name
plugname = str(self.TX_pluginName.text())
if plugname.find(" ")!=-1:
raise Exception , "pluginName can't contain spaces"
datas["$PLUGINNAME"]=plugname
datas["$AUTHOR"]=self.TX_authorName.text()
datas["$DATE"]=datetime.datetime.now()
datas["$DOCS"]=self.TX_description.toPlainText()
# run the builder
AssistantLib.generate(datas)
if __name__ == "__main__":
App=QtGui.QApplication(sys.argv)
AssistantApp = Assistant()
AssistantApp.show()
App.exec_()