Logo Search packages:      
Sourcecode: calibre version File versions

def cssutils::css::cssstyledeclaration::CSSStyleDeclaration::_setCssText (   self,
  cssText 
) [private]

Setting this attribute will result in the parsing of the new value
and resetting of all the properties in the declaration block
including the removal or addition of properties.

:exceptions:
    - :exc:`~xml.dom.NoModificationAllowedErr`:
      Raised if this declaration is readonly or a property is readonly.
    - :exc:`~xml.dom.SyntaxErr`:
      Raised if the specified CSS string value has a syntax error and
      is unparsable.

Definition at line 266 of file cssstyledeclaration.py.

00266                                   :
        """Setting this attribute will result in the parsing of the new value
        and resetting of all the properties in the declaration block
        including the removal or addition of properties.

        :exceptions:
            - :exc:`~xml.dom.NoModificationAllowedErr`:
              Raised if this declaration is readonly or a property is readonly.
            - :exc:`~xml.dom.SyntaxErr`:
              Raised if the specified CSS string value has a syntax error and
              is unparsable.
        """
        self._checkReadonly()
        tokenizer = self._tokenize2(cssText)

        # for closures: must be a mutable
        new = {'wellformed': True} 
        def ident(expected, seq, token, tokenizer=None):
            # a property
            
            tokens = self._tokensupto2(tokenizer, starttoken=token,
                                       semicolon=True)
            if self._tokenvalue(tokens[-1]) == u';':
                tokens.pop()
            property = Property(parent=self)
            property.cssText = tokens
            if property.wellformed:
                seq.append(property, 'Property')                
            else:
                self._log.error(u'CSSStyleDeclaration: Syntax Error in Property: %s'
                                % self._valuestr(tokens))
            # does not matter in this case
            return expected 

        def unexpected(expected, seq, token, tokenizer=None):
            # error, find next ; or } to omit upto next property
            ignored = self._tokenvalue(token) + self._valuestr(
                                self._tokensupto2(tokenizer, propertyvalueendonly=True))
            self._log.error(u'CSSStyleDeclaration: Unexpected token, ignoring upto %r.' %
                            ignored,token)
            # does not matter in this case
            return expected

        # [Property: Value;]* Property: Value?
        newseq = self._tempSeq()
        wellformed, expected = self._parse(expected=None,
            seq=newseq, tokenizer=tokenizer,
            productions={'IDENT': ident},#, 'CHAR': char},
            default=unexpected)
        # wellformed set by parse

        for item in newseq:
            item.value._parent = self
         
        # do not check wellformed as invalid things are removed anyway            
        self._setSeq(newseq)
        
    cssText = property(_getCssText, _setCssText,


Generated by  Doxygen 1.6.0   Back to index