This file is indexed.

/usr/share/pyshared/mayavi/components/optional.py is in mayavi2 4.1.0-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
"""A meta-component that allows a component to be optionally enabled
or disabled.  This component is mostly for illustration and is not
used anywhere.  This is because it is usually much easier to simply
add a trait in the module to enable/disable a particular component.

"""
# Author: Prabhu Ramachandran <prabhu_r@users.sf.net>
# Copyright (c) 2005, Enthought, Inc.
# License: BSD Style.

# Enthought library imports.
from traits.api import Instance, Bool, Str, Property
from traitsui.api import View, Group, Item

# Local imports.
from mayavi.core.component import Component


######################################################################
# `Optional` class.
######################################################################
class Optional(Component):
    # The version of this class.  Used for persistence.
    __version__ = 0

    # The outputs of this component is a property and not a list.
    outputs = Property

    # The component that is enabled or disabled.
    component = Instance(Component)

    # Is the component enabled or not.
    enabled = Bool(True, desc='if the component is enabled')

    # The label of the checkbox to use in the view.
    label = Str

    ########################################
    # The component's view

    # This is defined outside the view so that the label may be easily
    # changed.
    enabled_item = Item(name='enabled')
    view = View(Group(Group(enabled_item),
                      Group(Item(name='component', style='custom',
                                 visible_when='object.enabled'),
                            show_labels=False)
                      )
                )

    ######################################################################
    # `Component` interface
    ######################################################################
    def update_pipeline(self):
        """Override this method so that it *updates* the tvtk pipeline
        when data upstream is known to have changed.

        This method is invoked (automatically) when the input fires a
        `pipeline_changed` event.
        """
        comp = self.component
        if self.inputs != comp.inputs:
            comp.inputs = self.inputs
        self.pipeline_changed = True

    def update_data(self):
        """Override this method to do what is necessary when upstream
        data changes.

        This method is invoked (automatically) when any of the inputs
        sends a `data_changed` event.
        """
        self.data_changed = True

    ######################################################################
    # `Base` interface
    ######################################################################
    def start(self):
        """This is invoked when this object is added to the mayavi
        pipeline.  Note that when start is invoked, all the other
        information for the pipeline should be already set.
        """
        # Do nothing if we are already running.
        if self.running:
            return

        super(Optional, self).start()
        self.component.start()

    def stop(self):
        """Invoked when this object is removed from the mayavi
        pipeline.
        """
        if not self.running:
            return

        self.component.stop()
        super(Optional, self).stop()

    ######################################################################
    # Non-public methods.
    ######################################################################
    def _get_outputs(self):
        if self.enabled:
            return self.component.outputs
        else:
            return self.inputs[0].outputs

    def _enabled_changed(self, value):
        # Force downstream modules to update.
        self.pipeline_changed = True

    def _label_changed(self, value):
        # Change the displayed label for the enable trait in the view.
        item = self.trait_view_elements().content['enabled_item']
        item.label = value

    def _component_changed(self, old, new):
        if old is not None:
            old.on_trait_change(self._fire_pipeline_changed,
                                 'pipeline_changed', remove=True)
            old.on_trait_change(self._fire_data_changed,
                                 'data_changed', remove=True)

        new.on_trait_change(self._fire_pipeline_changed, 'pipeline_changed')
        new.on_trait_change(self._fire_data_changed, 'data_changed')

    def _fire_pipeline_changed(self):
        self.pipeline_changed = True

    def _fire_data_changed(self):
        self.data_changed = True