This file is indexed.

/usr/share/pyshared/cssutils/helper.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
"""cssutils helper
"""
__docformat__ = 'restructuredtext'
__version__ = '$Id: errorhandler.py 1234 2008-05-22 20:26:12Z cthedot $'

import os
import re
import sys
import urllib

class Deprecated(object):
    """This is a decorator which can be used to mark functions
    as deprecated. It will result in a warning being emitted
    when the function is used.

    It accepts a single paramter ``msg`` which is shown with the warning.
    It should contain information which function or method to use instead.
    """
    def __init__(self, msg):
        self.msg = msg

    def __call__(self, func):
        def newFunc(*args, **kwargs):
            import warnings
            warnings.warn("Call to deprecated method %r. %s" %
                            (func.__name__, self.msg),
                            category=DeprecationWarning,
                            stacklevel=2)
            return func(*args, **kwargs)
        newFunc.__name__ = func.__name__
        newFunc.__doc__ = func.__doc__
        newFunc.__dict__.update(func.__dict__)
        return newFunc

# simple escapes, all non unicodes
_simpleescapes = re.compile(ur'(\\[^0-9a-fA-F])').sub    
def normalize(x):
    """
    normalizes x, namely:

    - remove any \ before non unicode sequences (0-9a-zA-Z) so for
      x=="c\olor\" return "color" (unicode escape sequences should have
      been resolved by the tokenizer already)
    - lowercase
    """
    if x:
        def removeescape(matchobj):
            return matchobj.group(0)[1:]
        x = _simpleescapes(removeescape, x)
        return x.lower()
    else:
        return x

def path2url(path):
    """Return file URL of `path`"""
    return u'file:' + urllib.pathname2url(os.path.abspath(path))    

def pushtoken(token, tokens):
    """Return new generator starting with token followed by all tokens in 
    ``tokens``"""
    # TODO: may use itertools.chain?
    yield token
    for t in tokens:
        yield t
                  
def string(value):
    """
    Serialize value with quotes e.g.::
    
        ``a \'string`` => ``'a \'string'``
    """
    # \n = 0xa, \r = 0xd, \f = 0xc
    value = value.replace(u'\n', u'\\a ').replace(
                          u'\r', u'\\d ').replace(
                          u'\f', u'\\c ').replace(
                          u'"', u'\\"')
    
    if value.endswith(u'\\'):
        value = value[:-1] + u'\\\\'

    return u'"%s"' % value

def stringvalue(string):
    """
    Retrieve actual value of string without quotes. Escaped 
    quotes inside the value are resolved, e.g.::
    
        ``'a \'string'`` => ``a 'string``
    """
    return string.replace(u'\\'+string[0], string[0])[1:-1]

_match_forbidden_in_uri = re.compile(ur'''.*?[\(\)\s\;,'"]''', re.U).match
def uri(value):
    """
    Serialize value by adding ``url()`` and with quotes if needed e.g.::
    
        ``"`` => ``url("\"")`` 
    """
    if _match_forbidden_in_uri(value):
        value = string(value)
    return u'url(%s)' % value

def urivalue(uri):
    """
    Return actual content without surrounding "url(" and ")"
    and removed surrounding quotes too including contained 
    escapes of quotes, e.g.::
    
         ``url("\"")`` => ``"``
    """
    uri = uri[uri.find('(')+1:-1].strip()
    if uri and (uri[0] in '\'"') and (uri[0] == uri[-1]):
        return stringvalue(uri)
    else:
        return uri

#def normalnumber(num):
#    """
#    Return normalized number as string.
#    """
#    sign = ''
#    if num.startswith('-'):
#        sign = '-'
#        num = num[1:]
#    elif num.startswith('+'):
#        num = num[1:]
#
#    if float(num) == 0.0:
#        return '0'
#    else:        
#        if num.find('.') == -1:
#            return sign + str(int(num)) 
#        else: 
#            a, b = num.split('.')
#            if not a:
#                a = '0'
#            return '%s%s.%s' % (sign, int(a), b)