home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1525 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  5.2 KB  |  96 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __all__ = [
  5.     'CSSVariablesRule']
  6. __docformat__ = 'restructuredtext'
  7. __version__ = '$Id: cssfontfacerule.py 1818 2009-07-30 21:39:00Z cthedot $'
  8. from cssvariablesdeclaration import CSSVariablesDeclaration
  9. import cssrule
  10. import cssutils
  11. import xml.dom as xml
  12.  
  13. class CSSVariablesRule(cssrule.CSSRule):
  14.     
  15.     def __init__(self, mediaText = None, variables = None, parentRule = None, parentStyleSheet = None, readonly = False):
  16.         super(CSSVariablesRule, self).__init__(parentRule = parentRule, parentStyleSheet = parentStyleSheet)
  17.         self._atkeyword = u'@variables'
  18.         self._media = cssutils.stylesheets.MediaList(mediaText, readonly = readonly)
  19.         self._variables = CSSVariablesDeclaration(parentRule = self)
  20.         if variables:
  21.             self.variables = variables
  22.         
  23.         self._readonly = readonly
  24.  
  25.     
  26.     def __repr__(self):
  27.         return 'cssutils.css.%s(mediaText=%r, variables=%r)' % (self.__class__.__name__, self._media.mediaText, self.variables.cssText)
  28.  
  29.     
  30.     def __str__(self):
  31.         return '<cssutils.css.%s object mediaText=%r variables=%r valid=%r at 0x%x>' % (self.__class__.__name__, self._media.mediaText, self.variables.cssText, self.valid, id(self))
  32.  
  33.     
  34.     def _getCssText(self):
  35.         return cssutils.ser.do_CSSVariablesRule(self)
  36.  
  37.     
  38.     def _setCssText(self, cssText):
  39.         super(CSSVariablesRule, self)._setCssText(cssText)
  40.         tokenizer = self._tokenize2(cssText)
  41.         attoken = self._nexttoken(tokenizer, None)
  42.         if self._type(attoken) != self._prods.VARIABLES_SYM:
  43.             self._log.error(u'CSSVariablesRule: No CSSVariablesRule found: %s' % self._valuestr(cssText), error = xml.dom.InvalidModificationErr)
  44.         else:
  45.             oldvariables = CSSVariablesDeclaration()
  46.             oldvariables._absorb(self.variables)
  47.             ok = True
  48.             (beforetokens, brace) = self._tokensupto2(tokenizer, blockstartonly = True, separateEnd = True)
  49.             if self._tokenvalue(brace) != u'{':
  50.                 ok = False
  51.                 self._log.error(u'CSSVariablesRule: No start { of variable declaration found: %r' % self._valuestr(cssText), brace)
  52.             
  53.             new = {
  54.                 'wellformed': True }
  55.             newseq = self._tempSeq()
  56.             (beforewellformed, expected) = self._parse(expected = ':', seq = newseq, tokenizer = self._tokenize2(beforetokens), productions = { })
  57.             if ok and beforewellformed:
  58.                 pass
  59.             ok = new['wellformed']
  60.             (variablestokens, braceorEOFtoken) = self._tokensupto2(tokenizer, blockendonly = True, separateEnd = True)
  61.             val = self._tokenvalue(braceorEOFtoken)
  62.             typ = self._type(braceorEOFtoken)
  63.             if val != u'}' and typ != 'EOF':
  64.                 ok = False
  65.                 self._log.error(u'CSSVariablesRule: No "}" after variables declaration found: %r' % self._valuestr(cssText))
  66.             
  67.             nonetoken = self._nexttoken(tokenizer)
  68.             if nonetoken:
  69.                 ok = False
  70.                 self._log.error(u'CSSVariablesRule: Trailing content found.', token = nonetoken)
  71.             
  72.             if 'EOF' == typ:
  73.                 variablestokens.append(braceorEOFtoken)
  74.             
  75.             self.variables.cssText = variablestokens
  76.             if ok:
  77.                 self._setSeq(newseq)
  78.             else:
  79.                 self.variables._absorb(oldvariables)
  80.  
  81.     cssText = property(_getCssText, _setCssText, doc = '(DOM) The parsable textual representation of this rule.')
  82.     
  83.     def _setVariables(self, variables):
  84.         self._checkReadonly()
  85.         if isinstance(variables, basestring):
  86.             self._variables.cssText = variables
  87.         else:
  88.             self._variables = variables
  89.             self._variables.parentRule = self
  90.  
  91.     variables = property((lambda self: self._variables), _setVariables, doc = '(DOM) The variables of this rule set, a :class:`~cssutils.css.CSSVariablesDeclaration`.')
  92.     type = property((lambda self: self.VARIABLES_RULE), doc = 'The type of this rule, as defined by a CSSRule type constant.')
  93.     valid = property((lambda self: True), doc = 'TODO')
  94.     wellformed = property((lambda self: True))
  95.  
  96.