This file is indexed.

/usr/lib/python2.7/dist-packages/chaco/example_support.py is in python-chaco 4.4.1-1.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
 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
doc = \
"""
This file contains a support class that wraps up the boilerplate toolkit calls
that virtually all the demo programs have to use, and doesn't actually do
anything when run on its own.

Try running simple_line.py, colormapped_scatter.py, or check out any of
the programs in in tutorials/.
"""

from numpy import array

from traits.etsconfig.api import ETSConfig


# Set up the debug logger for all chaco examples.
# We don't want users to go digging around for the default Enthought logfile
# in ~/envisage.log, so we add a handler to the global logger for a file
# "chaco.log" in the current directory.

#import logging, logging.handlers
#try:
#    chaco_handler = logging.handlers.RotatingFileHandler("chaco.log",
#                        maxBytes=1000000, backupCount=0)
#    logging.getLogger().addHandler(chaco_handler)
#except:
#    # If we can't override the default handler, it's OK.
#    pass


# Import a default palette for backwards compatibility
from default_colors import cbrewer as COLOR_PALETTE


# FIXME - it should be enough to do the following import, but because of the
# PyQt/traits problem (see below) we can't because it would drag in traits too
# early.  Until it is fixed we just assume wx if we can import it.
# Force the selection of a valid toolkit.
#import enable.toolkit
if not ETSConfig.toolkit:
    for toolkit, toolkit_module in (('wx', 'wx'), ('qt4', 'pyface.qt')):
        try:
            __import__(toolkit_module)
            ETSConfig.toolkit = toolkit
            break
        except ImportError:
            pass
    else:
        raise RuntimeError("Can't load wx or qt4 backend for Chaco.")


if ETSConfig.toolkit == 'wx':
    import wx

    class DemoFrame(wx.Frame):
        """ Wraps boilerplate WX calls that almost all the demo programs have
        to use.
        """
        def __init__ ( self, *args, **kw ):
            wx.Frame.__init__( *(self,) + args, **kw )
            self.SetAutoLayout( True )

            # Create the subclass's window
            self.plot_window = self._create_window()

            sizer = wx.BoxSizer(wx.HORIZONTAL)
            sizer.Add(self.plot_window.control, 1, wx.EXPAND)
            self.SetSizer(sizer)
            self.Show( True )
            return

        def _create_window(self):
            "Subclasses should override this method and return an enable.wx.Window"
            raise NotImplementedError


    def demo_main(demo_class, size=(400,400), title="Chaco plot"):
        "Takes the class of the demo to run as an argument."
        app = wx.PySimpleApp()
        frame = demo_class(None, size=size, title=title)
        app.SetTopWindow(frame)
        app.MainLoop()

elif ETSConfig.toolkit == 'qt4':
    from pyface.qt import QtGui

    _app = QtGui.QApplication.instance()

    if _app is None:
        import sys
        _app = QtGui.QApplication(sys.argv)

    class DemoFrame(QtGui.QWidget):
        def __init__ (self, parent, **kw):
            QtGui.QWidget.__init__(self)

            # Create the subclass's window
            self.plot_window = self._create_window()

            layout = QtGui.QVBoxLayout()
            layout.setMargin(0)
            layout.addWidget(self.plot_window.control)

            self.setLayout(layout)

            if 'size' in kw:
                self.resize(*kw['size'])

            if 'title' in kw:
                self.setWindowTitle(kw['title'])

            self.show()

        def _create_window(self):
            "Subclasses should override this method and return an enable.Window"
            raise NotImplementedError


    def demo_main(demo_class, size=(400,400), title="Chaco plot"):
        "Takes the class of the demo to run as an argument."
        frame = demo_class(None, size=size, title=title)
        _app.exec_()

elif ETSConfig.toolkit == 'pyglet':
    from enable.pyglet_backend.pyglet_app import get_app, PygletApp

    class DemoFrame(object):
        def __init__(self):
            app = get_app()
            if app:
                window = self._create_window()
                self.enable_win = window
                app.add_window(window.control)
            return

        def _create_window(self):
            raise NotImplementedError

    def demo_main(demo_class, size=(640,480), title="Chaco Example"):
        """ Runs a simple application in Pyglet using an instance of
        **demo_class** as the main window or frame.

        **demo_class** should be a subclass of DemoFrame or the pyglet
        backend's Window class.
        """
        app = PygletApp()
        if issubclass(demo_class, DemoFrame):
            frame = demo_class()
            window = frame.enable_win.control
        else:
            window = demo_class().control
        if not window._fullscreen:
            window.set_size(*size)
        window.set_caption(title)
        app.set_main_window(window)
        app.run()


if __name__ == "__main__":
    print "\n" + doc + "\n"

# EOF