This file is indexed.

/usr/share/pyshared/cssutils/css/cssvariablesrule.py is in python-cssutils 0.9.10-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
"""CSSVariables implements (and only partly) experimental 
`CSS Variables <http://disruptive-innovations.com/zoo/cssvariables/>`_
"""
__all__ = ['CSSVariablesRule']
__docformat__ = 'restructuredtext'
__version__ = '$Id: cssfontfacerule.py 1818 2009-07-30 21:39:00Z cthedot $'

from cssvariablesdeclaration import CSSVariablesDeclaration
import cssrule
import cssutils
import xml.dom

class CSSVariablesRule(cssrule.CSSRule):
    """
    The CSSVariablesRule interface represents a @variables rule within a CSS
    style sheet. The @variables rule is used to specify variables.

    cssutils uses a :class:`~cssutils.css.CSSVariablesDeclaration`  to
    represent the variables.
    
    Format::
    
        variables
            VARIABLES_SYM S* medium [ COMMA S* medium ]* LBRACE S* 
            variableset* '}' S*
            ;
        
    for variableset see :class:`cssutils.css.CSSVariablesDeclaration`
         
    **Media are not implemented. Reason is that cssutils is using CSS
    variables in a kind of preprocessing and therefor no media information
    is available at this stage. For now do not use media!**
    
    Example::
    
        @variables {
          CorporateLogoBGColor: #fe8d12;
        }
        
        div.logoContainer {
          background-color: var(CorporateLogoBGColor);
        }
    """
    def __init__(self, mediaText=None, variables=None, parentRule=None, 
                 parentStyleSheet=None, readonly=False):
        """
        If readonly allows setting of properties in constructor only.
        """
        super(CSSVariablesRule, self).__init__(parentRule=parentRule, 
                                              parentStyleSheet=parentStyleSheet)
        self._atkeyword = u'@variables'
        
        # dummy
        self._media = cssutils.stylesheets.MediaList(mediaText, 
                                                     readonly=readonly)
        
        if variables:
            self.variables = variables
        else: 
            self.variables = CSSVariablesDeclaration(parentRule=self)

        self._readonly = readonly
        
    def __repr__(self):
        return u"cssutils.css.%s(mediaText=%r, variables=%r)" % (
                self.__class__.__name__, 
                self._media.mediaText,
                self.variables.cssText)

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

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

    def _setCssText(self, cssText):
        """
        :exceptions:
            - :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.HierarchyRequestErr`:
              Raised if the rule cannot be inserted at this point in the
              style sheet.
            - :exc:`~xml.dom.NoModificationAllowedErr`:
              Raised if the rule is readonly.
              
        Format::
        
            variables
            : VARIABLES_SYM S* medium [ COMMA S* medium ]* LBRACE S* 
              variableset* '}' S*
            ;
            
            variableset
            : LBRACE S* vardeclaration [ ';' S* vardeclaration ]* '}' S*
            ;
        """
        super(CSSVariablesRule, self)._setCssText(cssText)

        tokenizer = self._tokenize2(cssText)
        attoken = self._nexttoken(tokenizer, None)
        if self._type(attoken) != self._prods.VARIABLES_SYM:
            self._log.error(u'CSSVariablesRule: No CSSVariablesRule found: %s' %
                            self._valuestr(cssText),
                            error=xml.dom.InvalidModificationErr)
        else:
            newVariables = CSSVariablesDeclaration(parentRule=self)
            ok = True
            
            beforetokens, brace = self._tokensupto2(tokenizer, 
                                                    blockstartonly=True,
                                                    separateEnd=True)            
            if self._tokenvalue(brace) != u'{':
                ok = False
                self._log.error(u'CSSVariablesRule: No start { of variable '
                                u'declaration found: %r' 
                                % self._valuestr(cssText), brace)
            
            # parse stuff before { which should be comments and S only
            new = {'wellformed': True}
            newseq = self._tempSeq()#[]
            
            beforewellformed, expected = self._parse(expected=':',
                seq=newseq, tokenizer=self._tokenize2(beforetokens),
                productions={})
            ok = ok and beforewellformed and new['wellformed']
    
            variablestokens, braceorEOFtoken = self._tokensupto2(tokenizer, 
                                                             blockendonly=True,
                                                             separateEnd=True)

            val, type_ = self._tokenvalue(braceorEOFtoken), \
                         self._type(braceorEOFtoken)
            if val != u'}' and type_ != 'EOF':
                ok = False
                self._log.error(u'CSSVariablesRule: No "}" after variables '
                                u'declaration found: %r'
                                % self._valuestr(cssText))
                
            nonetoken = self._nexttoken(tokenizer)
            if nonetoken:
                ok = False
                self._log.error(u'CSSVariablesRule: Trailing content found.',
                                token=nonetoken)

            if 'EOF' == type_:
                # add again as variables needs it
                variablestokens.append(braceorEOFtoken)
            # SET but may raise:
            newVariables.cssText = variablestokens

            if ok:
                # contains probably comments only upto {
                self._setSeq(newseq)
                self.variables = newVariables

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

    media = property(doc=u"NOT IMPLEMENTED! As cssutils resolves variables "\
                         u"during serializing media information is lost.")

    def _setVariables(self, variables):
        """
        :param variables:
            a CSSVariablesDeclaration or string
        """
        self._checkReadonly()
        if isinstance(variables, basestring):
            self._variables = CSSVariablesDeclaration(cssText=variables, 
                                                      parentRule=self)
        else:
            variables._parentRule = self
            self._variables = variables

    variables = property(lambda self: self._variables, _setVariables,
                         doc=u"(DOM) The variables of this rule set, a "
                             u":class:`cssutils.css.CSSVariablesDeclaration`.")

    type = property(lambda self: self.VARIABLES_RULE, 
                    doc=u"The type of this rule, as defined by a CSSRule "
                        u"type constant.")

    valid = property(lambda self: True, doc='NOT IMPLEMTED REALLY (TODO)')
    
    # constant but needed:
    wellformed = property(lambda self: True)