home *** CD-ROM | disk | FTP | other *** search
Wrap
# Source Generated with Decompyle++ # File: in.pyc (Python 2.6) __all__ = [ 'CSSPageRule'] __docformat__ = 'restructuredtext' __version__ = '$Id: csspagerule.py 1868 2009-10-17 19:36:54Z cthedot $' from cssstyledeclaration import CSSStyleDeclaration from selectorlist import SelectorList import cssrule import cssutils import xml.dom as xml class CSSPageRule(cssrule.CSSRule): def __init__(self, selectorText = None, style = None, parentRule = None, parentStyleSheet = None, readonly = False): super(CSSPageRule, self).__init__(parentRule = parentRule, parentStyleSheet = parentStyleSheet) self._atkeyword = u'@page' tempseq = self._tempSeq() if selectorText: self.selectorText = selectorText tempseq.append(self.selectorText, 'selectorText') else: self._selectorText = self._tempSeq() self._style = CSSStyleDeclaration(parentRule = self) if style: self.style = style tempseq.append(self.style, 'style') self._setSeq(tempseq) self._readonly = readonly def __repr__(self): return 'cssutils.css.%s(selectorText=%r, style=%r)' % (self.__class__.__name__, self.selectorText, self.style.cssText) def __str__(self): return '<cssutils.css.%s object selectorText=%r style=%r at 0x%x>' % (self.__class__.__name__, self.selectorText, self.style.cssText, id(self)) def __parseSelectorText(self, selectorText): new = { 'wellformed': True, 'last-S': False } def _char(expected, seq, token, tokenizer = (None, None)): val = self._tokenvalue(token) if not new['last-S'] and expected in ('page', ': or EOF') and u':' == val: try: identtoken = tokenizer.next() except StopIteration: self._log.error(u'CSSPageRule selectorText: No IDENT found.', token) ival = self._tokenvalue(identtoken) ityp = self._type(identtoken) if self._prods.IDENT != ityp: self._log.error(u'CSSPageRule selectorText: Expected IDENT but found: %r' % ival, token) else: seq.append(val + ival, 'pseudo') return 'EOF' return self._prods.IDENT != ityp new['wellformed'] = False self._log.error(u'CSSPageRule selectorText: Unexpected CHAR: %r' % val, token) return expected def S(expected, seq, token, tokenizer = (None,)): if expected == ': or EOF': new['last-S'] = True return expected def IDENT(expected, seq, token, tokenizer = (None, None)): val = self._tokenvalue(token) if 'page' == expected: seq.append(val, 'IDENT') return ': or EOF' new['wellformed'] = False self._log.error(u'CSSPageRule selectorText: Unexpected IDENT: %r' % val, token) return expected def COMMENT(expected, seq, token, tokenizer = None): seq.append(cssutils.css.CSSComment([ token]), 'COMMENT') return expected newseq = self._tempSeq() (wellformed, expected) = self._parse(expected = 'page', seq = newseq, tokenizer = self._tokenize2(selectorText), productions = { 'CHAR': _char, 'IDENT': IDENT, 'COMMENT': COMMENT, 'S': S }, new = new) if wellformed: pass wellformed = new['wellformed'] if expected == 'ident': self._log.error(u'CSSPageRule selectorText: No valid selector: %r' % self._valuestr(selectorText)) return (wellformed, newseq) def _getCssText(self): return cssutils.ser.do_CSSPageRule(self) def _setCssText(self, cssText): super(CSSPageRule, self)._setCssText(cssText) tokenizer = self._tokenize2(cssText) if self._type(self._nexttoken(tokenizer)) != self._prods.PAGE_SYM: self._log.error(u'CSSPageRule: No CSSPageRule found: %s' % self._valuestr(cssText), error = xml.dom.InvalidModificationErr) else: oldstyle = CSSStyleDeclaration() oldstyle._absorb(self.style) ok = True (selectortokens, startbrace) = self._tokensupto2(tokenizer, blockstartonly = True, separateEnd = True) (styletokens, braceorEOFtoken) = self._tokensupto2(tokenizer, blockendonly = True, separateEnd = True) nonetoken = self._nexttoken(tokenizer) if self._tokenvalue(startbrace) != u'{': ok = False self._log.error(u'CSSPageRule: No start { of style declaration found: %r' % self._valuestr(cssText), startbrace) elif nonetoken: ok = False self._log.error(u'CSSPageRule: Trailing content found.', token = nonetoken) (selok, newselectorseq) = self._CSSPageRule__parseSelectorText(selectortokens) if ok: pass ok = selok val = self._tokenvalue(braceorEOFtoken) typ = self._type(braceorEOFtoken) if val != u'}' and typ != 'EOF': ok = False self._log.error(u'CSSPageRule: No "}" after style declaration found: %r' % self._valuestr(cssText)) elif 'EOF' == typ: styletokens.append(braceorEOFtoken) self.style.cssText = styletokens if ok: self._selectorText = newselectorseq else: self.style._absorb(oldstyle) cssText = property(_getCssText, _setCssText, doc = '(DOM) The parsable textual representation of this rule.') def _getSelectorText(self): return cssutils.ser.do_CSSPageRuleSelector(self._selectorText) def _setSelectorText(self, selectorText): self._checkReadonly() (wellformed, newseq) = self._CSSPageRule__parseSelectorText(selectorText) if wellformed: self._selectorText = newseq selectorText = property(_getSelectorText, _setSelectorText, doc = '(DOM) The parsable textual representation of the page selector for the rule.') def _setStyle(self, style): self._checkReadonly() if isinstance(style, basestring): self._style.cssText = style else: self._style = style self._style.parentRule = self style = property((lambda self: self._style), _setStyle, doc = '(DOM) The declaration-block of this rule set, a :class:`~cssutils.css.CSSStyleDeclaration`.') type = property((lambda self: self.PAGE_RULE), doc = 'The type of this rule, as defined by a CSSRule type constant.') wellformed = property((lambda self: True))