Logo Search packages:      
Sourcecode: ocrfeeder version File versions  Download package

def odf::element::Element::addAttribute (   self,
  attr,
  value 
)

Add an attribute to the element
    This is sort of a convenience method. All attributes in ODF have
    namespaces. The library knows what attributes are legal and then allows
    the user to provide the attribute as a keyword argument and the
    library will add the correct namespace.

Definition at line 185 of file element.py.

00185                                        :
        """ Add an attribute to the element
            This is sort of a convenience method. All attributes in ODF have
            namespaces. The library knows what attributes are legal and then allows
            the user to provide the attribute as a keyword argument and the
            library will add the correct namespace.
        """
        allowed_attrs = self.allowed_attributes()
        if allowed_attrs is None:
            if type(attr) == type(()):
                prefix, localname = attr
                self.addAttrNS(prefix, localname, value)
            else:
                raise AttributeError, "Unable to add simple attribute - use (namespace, localpart)"
        else:
            # Construct a list of allowed arguments
            allowed_args = [ a[1].lower().replace('-','') for a in allowed_attrs]
            if attr not in allowed_args:
                raise AttributeError, "Attribute %s is not allowed in <%s>" % ( attr, self.type)
            i = allowed_args.index(attr)
            self.addAttrNS(allowed_attrs[i][0], allowed_attrs[i][1], value)

    def addAttrNS(self, namespace, localpart, value):


Generated by  Doxygen 1.6.0   Back to index