This file is indexed.

/usr/lib/python2.7/dist-packages/chaco/plot_template.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
"""
Defines classes needed to support templates in Chaco.

* AbstractTemplatizer
* CodeMetadata
* CodeTemplate
* PlotTemplate
* PlotTemplateException
* TemplateDescriptor
* Templatizable

Also defines the convenience function::

    bind_template(template, vars, type_check=False)

"""


from traits.api import Bool, Dict, HasTraits, Instance, Str



def bind_template(template, vars, type_check=False):
    """
    A convenience method for binding a plot template to set of variables.

    Parameters
    ----------
    template : a list of strings
        The code for the template, or a PlotTemplate object.
    vars : a dict
        Maps a template variable name to an object.
    type_check : Boolean
        If True, raises a PlotTemplateException with the name
        of the variable in *vars* whose type does not match what is
        specified in the template.
    """
    return


class PlotTemplateException(Exception):
    """ Raised for errors in plot templates.
    """
    pass


class TemplateDescriptor(HasTraits):
    """ Describes the names and types of template variables for a template.
    """

    # A dict with the template variable names as keys.  If the template is
    # unbound, the values are string representations of the types of objects
    # expected for each key.  These are simple types, e.g., 'tuple' or
    # 'PlotAxis'. If the template is bound, then the values are object
    # references.
    vars = Dict




class Templatizable(HasTraits):
    """ Mix-in class that makes objects capable of being incorporated
    into a Chaco template.

    Primarily defines the protocol used to query the class for its contents.
    """

    def templatize(self, my_name, ):
        """ Returns a dict mapping the name of the child in the local name space
        to a Templatizable object reference.
        """
        raise NotImplementedError

    def __gettemplate__(self):
        """ Returns a templatized version of the object.
        """

#    def bind(self,

    def rebind(self, obj):
        """ Replaces this object with the state in peer object *obj*.

        This method allows PlotTemplates to be used as live, application-level
        templates and not merely as a means to generating a plot script.

        (If you are having trouble implementing this method for something that
        should be Templatizable, it's probably a sign that you haven't fully
        considered the implications of your design, or that you are doing
        something a little weird.)
        """
        raise NotImplementedError


class PlotTemplate(HasTraits):
    """ Abstract base class for plot templates.
    """
    pass




class AbstractTemplatizer(HasTraits):
    """ A Templatizer accepts any subclass of Templatizable and returns a
    PlotTemplate.
    """



class CodeMetadata(HasTraits):
    """ Represents all the metadata about a plot template, to be stored into
    the generated code.

    The generated code for a plot template must create one of these objects,
    which is then used to drive the loading of the rest of the template.
    """
    # Not used for now, but could be handled later.
    version = "1.0"

    # The name of the Chaco package.
    pkg_name = "chaco"

    # A dict with the template variable names as keys.  If the template is
    # unbound, the values are string representations of the types of objects
    # expected for each key. These are simple types, e.g., 'tuple' or 'PlotAxis'.
    # If the template is bound, then the values are object references.
    template_vars = Dict

    # The name to evaluate to get the root object when the template
    # is instantiated.  Defaults to "ROOT_OBJ", but you can customize
    # this for aesthetic or readability reasons.
    root_name = Str

class CodeTemplate(PlotTemplate):
    """ A Chaco plot template.

    Because Chaco plot templates are just executable code that produces Chaco
    plots, the PlotTemplate class is used to manage, interact with, and inspect
    the code for the template.
    """

    #-------------------------------------------------------------------------
    # Configuration and general state of the template
    #-------------------------------------------------------------------------

    # Is the template completely bound?
    is_bound = Bool(False)


    #-------------------------------------------------------------------------
    # Object graph traits
    #-------------------------------------------------------------------------

    # The top-level Templatizable component in the plot.
    root = Instance(Templatizable)

    #-------------------------------------------------------------------------
    # Code-related traits
    # These are used during the actual code generation process.
    #-------------------------------------------------------------------------

    # Global variables used during the code generation process.
    code_globals = Dict
    # Imports used during the code generation process.
    code_imports = Dict

    def create_strings(self):
        """ Returns a list of strings which can be passed to bind_template().
        """
        # TODO:  do we need this?? can we do live generation?!!!
        pass

    def load_from_strings(self, stringlist):
        """ Fills this plot template with the template in *stringlist*.

        NOTE: Don't use this to bind a template to data!  There is a much easier
        way to do that: use the bind_template() function.
        """
        pass

    #-------------------------------------------------------------------------
    # Private methods
    #-------------------------------------------------------------------------

    def _write_metadata(self):
        """
        Produces a list of strings representing the code to create the
        metadata portion of this PlotTemplate.
        """
        pass

    #-------------------------------------------------------------------------
    # Methods used by Templatizable objects to query the generator about the
    # state of code generation.
    #-------------------------------------------------------------------------

    def create_global(self, name_hint):
        """ Requests that a new global symbol be allocated with the given name.

        Returns the actual name that was created.
        """
        pass

    def create_import(self, import_line, ):
        """ Adds another import line, verbatim, to the top of the output code.

        No order of imports is guaranteed.
        """
        pass

    def create_template_var(self, name_hint):
        """ Creates a new variable for parameterizing the template.

        Returns a string that represents the special token to be used in the
        output code to signal where the template value can be bound.
        """
        pass

    def create_function(self, name_hint):
        """ Requests that a new function be allocated with the given name.

        Returns the actual name that was created.
        """
        pass


# EOF