コード例 #1
0
ファイル: __init__.py プロジェクト: gdw2/zim
	def _get_object(self, elt):
		## TODO optimize using self._object_cache or new API for
		## passing on objects in the tree
		type = elt.attrib.get('type')
		if elt.tag == OBJECT and type:
			return ObjectManager.get_object(type, elt.attrib, elt.text)
		else:
			return None
コード例 #2
0
ファイル: __init__.py プロジェクト: fabricehong/zim-desktop
 def _get_object(self, elt):
     ## TODO optimize using self._object_cache or new API for
     ## passing on objects in the tree
     type = elt.attrib.get('type')
     if elt.tag == OBJECT and type:
         return ObjectManager.get_object(type, elt.attrib, elt.text)
     else:
         return None
コード例 #3
0
ファイル: __init__.py プロジェクト: gdw2/zim
	def dump_object(self, tag, attrib, strings=None):
		'''Dumps object using proper ObjectManager'''
		format = str(self.__class__.__module__).split('.')[-1]
		if 'type' in attrib:
			obj = ObjectManager.get_object(attrib['type'], attrib, u''.join(strings))
			output = obj.dump(format, self, self.linker)
			if output is not None:
				return [output]

		return self.dump_object_fallback(tag, attrib, strings)
コード例 #4
0
    def dump_object(self, tag, attrib, strings=None):
        '''Dumps object using proper ObjectManager'''
        format = str(self.__class__.__module__).split('.')[-1]
        if 'type' in attrib:
            obj = ObjectManager.get_object(attrib['type'], attrib,
                                           u''.join(strings))
            output = obj.dump(format, self, self.linker)
            if output is not None:
                return [output]

        return self.dump_object_fallback(tag, attrib, strings)
コード例 #5
0
 def _action_handler(self, action):
     try:
         name = action.get_name()[7:]  # len('insert_') = 7
         obj = ObjectManager.get_object(name)
         try:
             attrib, data = obj.new_object_interactive(self.pageview)
         except ValueError:
             return  # dialog cancelled
         self.pageview.insert_object(attrib, data)
     except:
         zim.errors.exception_handler('Exception during action: %s' %
                                      tool.name)
コード例 #6
0
ファイル: __init__.py プロジェクト: rayleyva/zim-desktop-wiki
	def dump_object(self, tag, attrib, strings=[]):
		'''Dumps objects defined by L{InsertedObjectType}'''
		format = str(self.__class__.__module__).split('.')[-1]
		try:
			obj = ObjectManager.get_object(attrib['type'])
		except KeyError:
			pass
		else:
			try:
				output = obj.format(format, self, attrib, ''.join(strings))
			except ValueError:
				pass
			else:
				assert isinstance(output, list)
				return output

		return self.dump_object_fallback(tag, attrib, strings)