This file is indexed.

/usr/share/pyshared/PyMetrics/utils.py is in pymetrics 0.8.1-6.

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
""" Utility functions used throughout the PyMetrics system.

    $Id: utils.py,v 1.2 2005/09/17 04:28:12 rcharney Exp $
"""

import sys
import token
import re

def sqlQ( s ):
    """ Place single quotes around strings and escaping existing single quotes."""
    a = s.replace( "\\","\\\\" )
    a = a.replace( "'", "\\'" )
    a = a.replace( '"', '\\"' )
    return '"'+a+'"'
    
def csvQ( s ):
    """ Quote a string using rules for CSV data."""
    a = s.replace("\\","\\\\")
    b = a.replace( "'", "\\'" )
    c = b.replace( "\n", "\\n" )
    d = c.replace( '"', '""' )
    return '"'+d+'"'
    
def toTypeName( context, lst ):
    """ Convert token type numbers to names."""
    lstOut = []
    for name,blockDepth,semtype in lst:
        try:
            semName = token.tok_name[semtype]
            lstOut.append( (name,blockDepth,semName) )
        except KeyError, e:
            raise KeyError( "Unknown value '"+str( e )+"' for token/semantic type in context %s\n" % context )
    
    return lstOut
    
if 0:
    def mainTest():
        """ Built-in tests """
        def check( qs, s ):
            print "<%s>==<%s>" % (s.__repr__(),qs.__repr__())
            print "[%s]==[%s]" % (s,qs)
            try:
              assert( s.__repr__() == qs.__repr__() )
              assert( s, qs )
            except AssertionError:
              print "Failed"
        
        s0 = ''; qs0 = sqlQ(s0)
        check( qs0,  '""' )
        s1 = 'aName'; qs1 = sqlQ(s1)
        check( qs1, '"aName"' )
        s2 = 'A literal with a double quote (\") in it'; qs2 = sqlQ( s2 )
        check( qs2, '"A literal with a double quote (\\\") in it"' )
        s3 = '\'A literal with a single quote (\') in it\''; qs3 = sqlQ( s3 )
        check( qs3, '"\\\'A literal with a single quote (\\\') in it\\\'"' )
        s4 = """A multi-
    line literal."""; qs4 = sqlQ( s4 )
        check( qs4, '"A multi-\nline literal."' )
        
    if __name__ == "__main__":
        mainTest()