This file is indexed.

/usr/share/pyshared/runsnakerun/pstatsadapter.py is in runsnakerun 2.0.4-2.

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
import wx, sys, os, logging
log = logging.getLogger( __name__ )
from squaremap import squaremap
from runsnakerun import pstatsloader

class PStatsAdapter(squaremap.DefaultAdapter):

    percentageView = False
    total = 0
    
    TREE = pstatsloader.TREE_CALLS

    def value(self, node, parent=None):
        if isinstance(parent, pstatsloader.PStatGroup):
            if parent.cumulative:
                return node.cumulative / parent.cumulative
            else:
                return 0
        elif parent is None:
            return node.cumulative
        return parent.child_cumulative_time(node)

    def label(self, node):
        if isinstance(node, pstatsloader.PStatGroup):
            return '%s / %s' % (node.filename, node.directory)
        if self.percentageView and self.total:
            time = '%0.2f%%' % round(node.cumulative * 100.0 / self.total, 2)
        else:
            time = '%0.3fs' % round(node.cumulative, 3)
        return '%s@%s:%s [%s]' % (node.name, node.filename, node.lineno, time)

    def empty(self, node):
        if node.cumulative:
            return node.local / float(node.cumulative)
        return 0.0

    def parents(self, node):
        """Determine all parents of node in our tree"""
        return [
            parent for parent in
            getattr( node, 'parents', [] )
            if getattr(parent, 'tree', self.TREE) == self.TREE
        ]

    color_mapping = None

    def background_color(self, node, depth):
        """Create a (unique-ish) background color for each node"""
        if self.color_mapping is None:
            self.color_mapping = {}
        color = self.color_mapping.get(node.key)
        if color is None:
            depth = len(self.color_mapping)
            red = (depth * 10) % 255
            green = 200 - ((depth * 5) % 200)
            blue = (depth * 25) % 200
            self.color_mapping[node.key] = color = wx.Colour(red, green, blue)
        return color

    def SetPercentage(self, percent, total):
        """Set whether to display percentage values (and total for doing so)"""
        self.percentageView = percent
        self.total = total

    def filename( self, node ):
        """Extension to squaremap api to provide "what file is this" information"""
        if not node.directory:
            # TODO: any cases other than built-ins?
            return None
        if node.filename == '~':
            # TODO: look up C/Cython/whatever source???
            return None
        return os.path.join(node.directory, node.filename)
        

class DirectoryViewAdapter(PStatsAdapter):
    """Provides a directory-view-only adapter for PStats objects"""
    TREE = pstatsloader.TREE_FILES
    def children(self, node):
        if isinstance(node, pstatsloader.PStatGroup):
            return node.children
        return []