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


00001 """CSSComment is not defined in DOM Level 2 at all but a cssutils defined
class only.

Implements CSSRule which is also extended for a CSSComment rule type.
__all__ = ['CSSComment']
__docformat__ = 'restructuredtext'
__version__ = '$Id: csscomment.py 1638 2009-01-13 20:39:33Z cthedot $'

import cssrule
import cssutils
import xml.dom

00014 class CSSComment(cssrule.CSSRule):
    Represents a CSS comment (cssutils only).


    def __init__(self, cssText=None, parentRule=None, 
                 parentStyleSheet=None, readonly=False):
        super(CSSComment, self).__init__(parentRule=parentRule, 

        self._cssText = None
        if cssText:

        self._readonly = readonly

    def __repr__(self):
        return "cssutils.css.%s(cssText=%r)" % (
                self.__class__.__name__, self.cssText)

    def __str__(self):
        return "<cssutils.css.%s object cssText=%r at 0x%x>" % (
                self.__class__.__name__, self.cssText, id(self))

00041     def _getCssText(self):
        """Return serialized property cssText."""
        return cssutils.ser.do_CSSComment(self)

00045     def _setCssText(self, cssText):
        :param cssText:
            textual text to set or tokenlist which is not tokenized
            anymore. May also be a single token for this rule

            - :exc:`~xml.dom.SyntaxErr`:
              Raised if the specified CSS string value has a syntax error and
              is unparsable.
            - :exc:`~xml.dom.InvalidModificationErr`:
              Raised if the specified CSS string value represents a different
              type of rule than the current one.
            - :exc:`~xml.dom.NoModificationAllowedErr`:
              Raised if the rule is readonly.
        super(CSSComment, self)._setCssText(cssText)
        tokenizer = self._tokenize2(cssText)

        commenttoken = self._nexttoken(tokenizer)
        unexpected = self._nexttoken(tokenizer)

        if not commenttoken or\
           self._type(commenttoken) != self._prods.COMMENT or\
            self._log.error(u'CSSComment: Not a CSSComment: %r' %
            self._cssText = self._tokenvalue(commenttoken)

    cssText = property(_getCssText, _setCssText,
        doc=u"The parsable textual representation of this rule.")

    type = property(lambda self: self.COMMENT, 
                    doc="The type of this rule, as defined by a CSSRule "
                        "type constant.")
    # constant but needed:
    wellformed = property(lambda self: True)

Generated by  Doxygen 1.6.0   Back to index