[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/generic/scriptengines/python
From:       Guillaume De Bure <guillaume.debure () gmail ! com>
Date:       2010-11-15 21:28:30
Message-ID: 20101115212830.5CF43AC8A0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1197449 by gdebure:

Allow Python dataengines to have main scripts *not* named main.py

 M  +6 -1      pydataengine.py  


--- trunk/KDE/kdebase/workspace/plasma/generic/scriptengines/python/pydataengine.py #1197448:1197449
@@ -46,7 +46,12 @@
             relpath = relpath[:-3]
         relpath = relpath.replace("/",".")
         self.module = __import__(self.pluginName+'.'+relpath)
-        self.pydataengine = self.module.main.CreateDataEngine(None)
+        # The script may not necessarily be called "main"
+        # So we use __dict__ to look up the right name
+        basename = os.path.basename(str(self.mainScript()))
+        basename = os.path.splitext(basename)[0]
+
+        self.pydat  aengine = self.module.__dict__[basename].CreateDataEngine(None)
         self.pydataengine.setDataEngine(self.dataEngine())
         self.pydataengine.setDataEngineScript(self)
         self.pydataengine.init()
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic