2 # Copyright 2008 Simon Edwards <simon@simonzone.com>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU Library General Public License as
6 # published by the Free Software Foundation; either version 2, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details
14 # You should have received a copy of the GNU Library General Public
15 # License along with this program; if not, write to the
16 # Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 from PyQt4
.QtCore
import *
20 from PyQt4
.QtGui
import *
21 from PyKDE4
.plasma
import Plasma
22 import plasma_importer
24 class PythonDataEngineScript(Plasma
.DataEngineScript
):
25 def __init__(self
, parent
):
26 Plasma
.DataEngineScript
.__init
__(self
,parent
)
27 self
.importer
= plasma_importer
.PlasmaImporter()
28 self
.initialized
= False
31 print("Script Name: " + self
.dataEngine().name())
33 self
.m_moduleName
= str(self
.dataEngine().pluginName())
34 print("pluginname: " + str(self
.dataEngine().pluginName()))
35 self
.plugin_name
= str(self
.dataEngine().pluginName()).replace('-','_')
37 self
.importer
.register_top_level(self
.plugin_name
, str(self
.dataEngine().package().path()))
39 print("mainscript: " + str(self
.dataEngine().package().filePath("mainscript")))
40 print("package path: " + str(self
.dataEngine().package().path()))
42 # import the code at the file name reported by mainScript()
43 self
.module
= __import__(self
.plugin_name
+'.main')
44 self
.pydataengine
= self
.module
.main
.CreateDataEngine(None)
45 #self.pydataengine.setDataEngine(self.dataEngine())
46 self
.pydataengine
.setDataEngineScript(self
)
47 self
.pydataengine
.init()
49 self
.initialized
= True
53 print("~PythonDataEngineScript()")
54 PythonAppletScript
.importer
.unregister_top_level(self
.plugin_name
)
55 self
.pydataengine
= None
58 return self
.pydataengine
.sources()
60 def serviceForSource(self
,source
):
61 return self
.pydataengine
.serviceForSource(source
)
63 def sourceRequestEvent(self
,name
):
64 return self
.pydataengine
.sourceRequestEvent(name
)
66 def updateSourceEvent(self
,source
):
67 return self
.pydataengine
.updateSourceEvent(source
)
69 def CreatePlugin(widget_parent
, parent
, component_data
):
70 return PythonDataEngineScript(parent
)