Exemple #1
0
	def load_module_attr(self, attr):
		try:
			module = self.load_module()
			if module is not None:
				return getattr(module, attr)
		except:
			warn_tb(INTERNAL, 'When importing plugin %s', self.module_name)
			raise SketchError(_("Cannot load plugin %(name)s.%(attr)s")
								% {'name':self.module_name, 'attr':attr})
Exemple #2
0
	def __call__(self, *args, **kw):
		try:
			module = self.load_module()
			if module is not None:
				return apply(getattr(module, self.class_name), args, kw)
		except:
			warn_tb(INTERNAL, 'When analysing plugin %s', self.module_name)
			raise SketchError('Cannot load filter %(name)s.%(message)s'
								% {'name':self.module_name,
									'message':self.class_name})
Exemple #3
0
def read_resource_file(filename, magic, errmsg, functions):
    file = open(filename, 'r')
    try:
        line = file.readline()
        if line[:len(magic)] != magic:
            raise SketchError(errmsg % filename)

        from app.skread import parse_sk_line

        linenr = 1
        while 1:
            line = file.readline()
            if not line:
                break
            linenr = linenr + 1
            try:
                parse_sk_line(line, functions)
            except:
                warn_tb(USER, '%s:%d', filename, linenr)
    finally:
        file.close()
Exemple #4
0
 def __call__(self, document, filename, file=None, options=None):
     if options is None:
         options = {}
     try:
         module = self.load_module()
     except:
         warn_tb(INTERNAL, 'When importing plugin %s', self.module_name)
         raise SketchError(
             _("Cannot load filter %(name)s") % {'name': self.module_name})
     if file is None:
         file = open(filename, 'wb')
         close = 1
     else:
         close = 0
     if module is not None:
         module.save(document, file, filename, options)
     if close:
         file.close()
     if self.format_name == NativeFormat:
         document.ClearEdited()
     self.UnloadPlugin()