Ejemplo n.º 1
0
	def loadPlugins(self, pluginFolder):
		os.chdir(getMainDir())
		
		pluginModulePath = pluginFolder.replace('/', '.')
		
		if runningExecutable():
			if platform.system() == 'Windows':
				# windows plugin folder
				pluginFolder = 'library/' + pluginFolder
			else:
				# os x plugin folder
				pluginFolder = './lib/python2.6/site-packages/' + pluginFolder
		else:
			pluginFolder = os.path.join(os.path.split(os.path.realpath(__file__))[0], '..', '..', pluginFolder)
		
		d = {}
		for filename in os.listdir(pluginFolder):
			if os.path.isdir(os.path.join (pluginFolder, filename)):
				continue

			extension = filename[filename.rfind('.')+1:len(filename)]
			if extension == 'py' and filename != '__init__.py':
				pluginModule = filename[0:filename.rfind('.')]
				theModule = __import__(pluginModulePath + pluginModule, fromlist='*')
				theClass = getattr(theModule, pluginModule)
				theObject = theClass(self.preferences)
				d[theObject.name] = theObject

		return d
Ejemplo n.º 2
0
    def loadPlots(self, preferences, pluginFolder):
        os.chdir(getMainDir())

        pluginModulePath = pluginFolder.replace('/', '.')

        if runningExecutable():
            if platform.system() == 'Windows':
                # windows plugin folder
                pluginFolder = 'library/' + pluginFolder
            else:
                # os x plugin folder
                pluginFolder = './lib/python2.6/site-packages/' + pluginFolder
        else:
            pluginFolder = os.path.join(
                os.path.split(os.path.realpath(__file__))[0], '..', '..',
                pluginFolder)

        for filename in os.listdir(pluginFolder):
            if os.path.isdir(os.path.join(pluginFolder, filename)):
                continue

            extension = filename[filename.rfind('.') + 1:len(filename)]
            if extension == 'py' and filename != '__init__.py':
                pluginModule = filename[0:filename.rfind('.')]
                theModule = __import__(pluginModulePath + pluginModule,
                                       fromlist='*')
                theClass = getattr(theModule, pluginModule)
                plot = theClass(preferences)

                self.plotClassDict[plot.name] = theClass
                self.plotDict[plot.name] = plot

        exploratoryPlots = []
        statisticalPlots = []
        for key in self.plotDict:
            if self.plotDict[key].type == 'Exploratory':
                exploratoryPlots.append(key)
            else:
                statisticalPlots.append(key)

        exploratoryPlots.sort(lambda a, b: cmp(a.upper(), b.upper()))
        statisticalPlots.sort(lambda a, b: cmp(a.upper(), b.upper()))

        for plotName in exploratoryPlots:
            self.cboPlots.addItem(plotName)

        self.cboPlots.insertSeparator(self.cboPlots.count())

        for plotName in statisticalPlots:
            self.cboPlots.addItem(plotName)

        self.display(self.defaultPlot, None, None)
        self.cboPlots.setCurrentIndex(self.cboPlots.findText(self.defaultPlot))
Ejemplo n.º 3
0
	def loadPlots(self, preferences, pluginFolder):
		os.chdir(getMainDir())
		
		pluginModulePath = pluginFolder.replace('/', '.')

		if runningExecutable():
			if platform.system() == 'Windows':
				# windows plugin folder
				pluginFolder = 'library/' + pluginFolder
			else:
				# os x plugin folder
				pluginFolder = './lib/python2.6/site-packages/' + pluginFolder
		else:		
			pluginFolder = os.path.join(os.path.split(os.path.realpath(__file__))[0], '..', '..', pluginFolder)
		
		for filename in os.listdir(pluginFolder):
			if os.path.isdir(os.path.join (pluginFolder, filename)):
				continue

			extension = filename[filename.rfind('.')+1:len(filename)]	
			if extension == 'py' and filename != '__init__.py':
				pluginModule = filename[0:filename.rfind('.')]
				theModule = __import__(pluginModulePath + pluginModule, fromlist='*')
				theClass = getattr(theModule, pluginModule)
				plot = theClass(preferences)
				
				self.plotClassDict[plot.name] = theClass
				self.plotDict[plot.name] = plot
			
		exploratoryPlots = []
		statisticalPlots = []
		for key in self.plotDict:
			if self.plotDict[key].type == 'Exploratory':
				exploratoryPlots.append(key)
			else:
				statisticalPlots.append(key)
				
		exploratoryPlots.sort(lambda a,b:cmp(a.upper(), b.upper()))
		statisticalPlots.sort(lambda a,b:cmp(a.upper(), b.upper()))
			
		for plotName in exploratoryPlots:
			self.cboPlots.addItem(plotName)
			
		self.cboPlots.insertSeparator(self.cboPlots.count())
			
		for plotName in statisticalPlots:
			self.cboPlots.addItem(plotName)
				
		self.display(self.defaultPlot, None, None)
		self.cboPlots.setCurrentIndex(self.cboPlots.findText(self.defaultPlot))