home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- __all__ = [
- 'CSSUnknownRule']
- __docformat__ = 'restructuredtext'
- __version__ = '$Id: cssunknownrule.py 1897 2009-12-17 22:09:06Z cthedot $'
- import cssrule
- import cssutils
- import xml.dom as xml
-
- class CSSUnknownRule(cssrule.CSSRule):
-
- def __init__(self, cssText = u'', parentRule = None, parentStyleSheet = None, readonly = False):
- super(CSSUnknownRule, self).__init__(parentRule = parentRule, parentStyleSheet = parentStyleSheet)
- self._atkeyword = None
- if cssText:
- self.cssText = 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))
-
-
- def _getCssText(self):
- return cssutils.ser.do_CSSUnknownRule(self)
-
-
- def _setCssText(self, cssText):
- super(CSSUnknownRule, self)._setCssText(cssText)
- tokenizer = self._tokenize2(cssText)
- attoken = self._nexttoken(tokenizer, None)
- if not attoken or self._type(attoken) != self._prods.ATKEYWORD:
- self._log.error(u'CSSUnknownRule: No CSSUnknownRule found: %s' % self._valuestr(cssText), error = xml.dom.InvalidModificationErr)
- else:
- new = {
- 'nesting': [],
- 'wellformed': True }
-
- def CHAR(expected, seq, token, tokenizer = (None, None)):
- (type_, val, line, col) = token
- if expected != 'EOF':
- if val in u'{[(':
- new['nesting'].append(val)
- elif val in u'}])':
- opening = {
- u'}': u'{',
- u']': u'[',
- u')': u'(' }[val]
-
- try:
- if new['nesting'][-1] == opening:
- new['nesting'].pop()
- else:
- raise IndexError()
- except IndexError:
- new['wellformed'] = False
- self._log.error(u'CSSUnknownRule: Wrong nesting of {, [ or (.', token = token)
- except:
- None<EXCEPTION MATCH>IndexError
-
-
- None<EXCEPTION MATCH>IndexError
- if val in u'};' and not new['nesting']:
- expected = 'EOF'
-
- seq.append(val, type_, line = line, col = col)
- return expected
- new['wellformed'] = False
- self._log.error(u'CSSUnknownRule: Expected end of rule.', token = token)
- return expected
-
-
- def FUNCTION(expected, seq, token, tokenizer = (None, None)):
- (type_, val, line, col) = token
- val = self._tokenvalue(token)
- if expected != 'EOF':
- new['nesting'].append(u'(')
- seq.append(val, type_, line = line, col = col)
- return expected
- new['wellformed'] = False
- self._log.error(u'CSSUnknownRule: Expected end of rule.', token = token)
- return expected
-
-
- def EOF(expected, seq, token, tokenizer = (None,)):
- for x in reversed(new['nesting']):
- closing = {
- u'{': u'}',
- u'[': u']',
- u'(': u')' }[x]
- seq.append(closing, closing)
-
- new['nesting'] = []
- return 'EOF'
-
-
- def INVALID(expected, seq, token, tokenizer = (None, None)):
- self._log.error(u'CSSUnknownRule: Bad syntax.', token = token, error = xml.dom.SyntaxErr)
- new['wellformed'] = False
- return expected
-
-
- def STRING(expected, seq, token, tokenizer = (None, None)):
- (type_, val, line, col) = token
- val = self._stringtokenvalue(token)
- if expected != 'EOF':
- seq.append(val, type_, line = line, col = col)
- return expected
- new['wellformed'] = False
- self._log.error(u'CSSUnknownRule: Expected end of rule.', token = token)
- return expected
-
-
- def URI(expected, seq, token, tokenizer = (None, None)):
- (type_, val, line, col) = token
- val = self._uritokenvalue(token)
- if expected != 'EOF':
- seq.append(val, type_, line = line, col = col)
- return expected
- new['wellformed'] = False
- self._log.error(u'CSSUnknownRule: Expected end of rule.', token = token)
- return expected
-
-
- def default(expected, seq, token, tokenizer = (None, None)):
- (type_, val, line, col) = token
- if expected != 'EOF':
- seq.append(val, type_, line = line, col = col)
- return expected
- new['wellformed'] = False
- self._log.error(u'CSSUnknownRule: Expected end of rule.', token = token)
- return expected
-
- newseq = self._tempSeq()
- (wellformed, expected) = self._parse(expected = None, seq = newseq, tokenizer = tokenizer, productions = {
- 'CHAR': CHAR,
- 'EOF': EOF,
- 'FUNCTION': FUNCTION,
- 'INVALID': INVALID,
- 'STRING': STRING,
- 'URI': URI,
- 'S': default }, default = default, new = new)
- if wellformed:
- pass
- wellformed = new['wellformed']
- if expected != 'EOF':
- wellformed = False
- self._log.error(u'CSSUnknownRule: No ending ";" or "}" found: %r' % self._valuestr(cssText))
- elif new['nesting']:
- wellformed = False
- self._log.error(u'CSSUnknownRule: Unclosed "{", "[" or "(": %r' % self._valuestr(cssText))
-
- if wellformed:
- self.atkeyword = self._tokenvalue(attoken)
- self._setSeq(newseq)
-
-
- cssText = property(fget = _getCssText, fset = _setCssText, doc = '(DOM) The parsable textual representation.')
- type = property((lambda self: self.UNKNOWN_RULE), doc = 'The type of this rule, as defined by a CSSRule type constant.')
- wellformed = property((lambda self: bool(self.atkeyword)))
-
-