Exemplo n.º 1
0
    def __init__(self, config=None):
        '''Constructor
		@param config: a L{ConfigManager} object that is used to load
		plugin preferences.
		Defaults to a L{VirtualConfigManager} for testing.
		'''
        assert 'name' in self.plugin_info, 'Missing "name" in plugin_info'
        assert 'description' in self.plugin_info, 'Missing "description" in plugin_info'
        assert 'author' in self.plugin_info, 'Missing "author" in plugin_info'
        self.extensions = WeakSet()

        if self.plugin_preferences:
            assert isinstance(
                self.plugin_preferences[0],
                tuple), 'BUG: preferences should be defined as tuples'

        self.config = config or VirtualConfigManager()
        self.preferences = self.config.get_config_dict(
            '<profile>/preferences.conf')[self.config_key]

        for pref in self.plugin_preferences:
            if len(pref) == 4:
                key, type, label, default = pref
                self.preferences.setdefault(key, default)
                #~ print ">>>>", key, default, '--', self.preferences[key]
            else:
                key, type, label, default, check = pref
                self.preferences.setdefault(key, default, check=check)
                #~ print ">>>>", key, default, check, '--', self.preferences[key]

        self.load_extensions_classes()
Exemplo n.º 2
0
    def __init__(self, config=None):
        '''Constructor
		@param config: a L{ConfigManager} object that is used to load
		plugin preferences.
		Defaults to a L{VirtualConfigManager} for testing.
		'''
        assert 'name' in self.plugin_info, 'Missing "name" in plugin_info'
        assert 'description' in self.plugin_info, 'Missing "description" in plugin_info'
        assert 'author' in self.plugin_info, 'Missing "author" in plugin_info'
        self.extensions = WeakSet()

        if self.plugin_preferences:
            assert isinstance(
                self.plugin_preferences[0],
                tuple), 'BUG: preferences should be defined as tuples'

        self.config = config or VirtualConfigManager()
        self.preferences = self.config.get_config_dict(
            '<profile>/preferences.conf')[self.config_key]
        self._init_config(self.preferences, self.plugin_preferences)
        self._init_config(self.preferences, self.plugin_notebook_properties
                          )  # defaults for the properties are preferences

        self.load_insertedobject_types()
        self.load_extensions_classes()
Exemplo n.º 3
0
    def __init__(self, plugin, objmap):

        #		InsertSymbolDialog(self.plugi).run()
        self._widgets = WeakSet()
        self.preferences = plugin.preferences
        InsertedObjectTypeExtension.__init__(self, plugin, objmap)
        self.connectto(self.preferences, 'changed',
                       self.on_preferences_changed)
Exemplo n.º 4
0
 def __init__(self, attrib, data, preferences):
     if data.endswith('\n'):
         data = data[:-1]
         # If we have trailing \n it looks like an extra empty line
         # in the buffer, so we default remove one
     CustomObjectClass.__init__(self, attrib, data)
     self.preferences = preferences
     self.buffer = None
     self._widgets = WeakSet()
Exemplo n.º 5
0
    def _reset(self):
        self._preferences = ConfigManager.preferences['General']
        self._preferences.setdefault('plugins', [])

        self._plugins = {}
        self._extendables = WeakSet()
        self.failed = set()

        self.insertedobjects = InsertedObjectTypeMap()
Exemplo n.º 6
0
	def __init__(self, config=None):
		self.config = config or VirtualConfigManager()
		self._preferences = \
			self.config.get_config_dict('<profile>/preferences.conf')
		self.general_preferences = self._preferences['General']
		self.general_preferences.setdefault('plugins', [])

		self._plugins = {}
		self._extendables = WeakSet()

		self._load_plugins()

		self.connectto(self._preferences, 'changed',
			self.on_preferences_changed)
Exemplo n.º 7
0
	def __init__(self):
		assert 'name' in self.plugin_info, 'Missing "name" in plugin_info'
		assert 'description' in self.plugin_info, 'Missing "description" in plugin_info'
		assert 'author' in self.plugin_info, 'Missing "author" in plugin_info'
		self.extensions = WeakSet()

		if self.plugin_preferences:
			assert isinstance(self.plugin_preferences[0], tuple), 'BUG: preferences should be defined as tuples'

		self.preferences = ConfigManager.preferences[self.config_key]
		self._init_config(self.preferences, self.plugin_preferences)
		self._init_config(self.preferences, self.plugin_notebook_properties) # defaults for the properties are preferences

		self.extension_classes = list(self.discover_classes(ExtensionBase))
Exemplo n.º 8
0
    def register_object(self, type, factory):
        '''Register a factory method or class for a specific object type.
		@param type: the object type as string (unique name)
		@param factory: can be either an object class or a method,
		should callable and return objects. When constructing objects
		this factory will be called as::

			factory(attrib, text)

		Where:
		  - C{attrib} is a dict with attributes
		  - C{text} is the main text source of the object

		@returns: a previously set factory for C{type} or C{None}
		'''
        logger.debug('Registered object %s', type)
        type = type.lower()
        old = self.factories.get(type)
        self.factories[type] = factory
        self.objects[type] = WeakSet()
        return old
Exemplo n.º 9
0
    def __init__(self, config=None):
        '''Constructor
		Constructor will directly load a list of default plugins
		based on the preferences in the config. Failures while loading
		these plugins will be logged but not raise errors.

		@param config: a L{ConfigManager} object that is passed along
		to the plugins and is used to load plugin preferences.
		Defaults to a L{VirtualConfigManager} for testing.
		'''
        self.config = config or VirtualConfigManager()
        self._preferences = \
         self.config.get_config_dict('<profile>/preferences.conf')
        self.general_preferences = self._preferences['General']
        self.general_preferences.setdefault('plugins', [])

        self._plugins = {}
        self._extendables = WeakSet()

        self._load_plugins()

        self.connectto(self._preferences, 'changed',
                       self.on_preferences_changed)
Exemplo n.º 10
0
    def __init__(self, attrib, header, rows, preferences):
        '''
		Creates a new object which can displayed within the page
		:param attrib: aligns, wraps
		:param header: titles of the table as list
		:param rows: body-rows of the table as list of lists
		:param preferences: optionally some preferences
		'''
        _attrib = {}
        for k, v in attrib.iteritems():
            if isinstance(v, list):
                v = ','.join(map(str, v))
            _attrib[k] = v
        CustomObjectClass.__init__(self, _attrib, [header] + rows)
        self.attrib = {'type': OBJECT_TYPE}  # just to be sure

        self._tableattrib = attrib
        self._header = header
        self._rows = rows
        self._widgets = WeakSet()
        self._liststore = None  # shared model between widgets

        self.preferences = preferences
Exemplo n.º 11
0
	def __init__(self, config=None):
		assert 'name' in self.plugin_info
		assert 'description' in self.plugin_info
		assert 'author' in self.plugin_info
		self.extensions = WeakSet()

		if self.plugin_preferences:
			assert isinstance(self.plugin_preferences[0], tuple), 'BUG: preferences should be defined as tuples'

		self.config = config or VirtualConfigManager()
		self.preferences = self.config.get_config_dict('<profile>/preferences.conf')[self.config_key]

		for pref in self.plugin_preferences:
				if len(pref) == 4:
					key, type, label, default = pref
					self.preferences.setdefault(key, default)
					#~ print ">>>>", key, default, '--', self.preferences[key]
				else:
					key, type, label, default, check = pref
					self.preferences.setdefault(key, default, check=check)
					#~ print ">>>>", key, default, check, '--', self.preferences[key]

		self.load_extensions_classes()
Exemplo n.º 12
0
 def __init__(self, plugin):
     InsertedObjectType.__init__(self, plugin)
     self._widgets = WeakSet()
     self.preferences = plugin.preferences
     self.connectto(self.preferences, 'changed',
                    self.on_preferences_changed)
Exemplo n.º 13
0
 def __init__(self):
     self.factories = {}
     self.objects = {'fallback': WeakSet()}
     self.window_extensions = {}
Exemplo n.º 14
0
 def __init__(self):
     self.factories = {}
     self.objects = {'fallback': WeakSet()}