This file is indexed.

/usr/lib/python2.7/dist-packages/wxglade/widgets/combo_box/codegen.py is in python-wxglade 0.6.8-2.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
# codegen.py: code generator functions for wxComboBox objects
# $Id: codegen.py,v 1.15 2007/03/27 07:02:02 agriggio Exp $
#
# Copyright (c) 2002-2007 Alberto Griggio <agriggio@users.sourceforge.net>
# License: MIT (see license.txt)
# THIS PROGRAM COMES WITH NO WARRANTY

import common
from ChoicesCodeHandler import *

class PythonCodeGenerator:
    def get_code(self, obj):
        pygen = common.code_writers['python']
        prop = obj.properties
        id_name, id = pygen.generate_code_id(obj)
        choices = prop.get('choices', [])
        if not obj.parent.is_toplevel: parent = 'self.%s' % obj.parent.name
        else: parent = 'self'
        style = prop.get("style", None)
        if not style: style = pygen.cn('wxCB_DROPDOWN')
        else: style = pygen.cn_f('wxCB_DROPDOWN|' + style)
        init = []
        if id_name: init.append(id_name)
        choices = ', '.join([pygen.quote_str(c) for c in choices])
        klass = obj.klass
        if klass == obj.base: klass = pygen.cn(klass)
        init.append('self.%s = %s(%s, %s, choices=[%s], style=%s)\n' %
                    (obj.name, klass, parent, id, choices, style))
        props_buf = pygen.generate_common_properties(obj)
        selection = prop.get('selection')
        if selection is not None and len(prop.get('choices', [])):
            props_buf.append('self.%s.SetSelection(%s)\n' %
                             (obj.name, selection))
        return init, props_buf, []

# end of class PythonCodeGenerator


def xrc_code_generator(obj):
    xrcgen = common.code_writers['XRC']
    class ComboBoxXrcObject(xrcgen.DefaultXrcObject):
        def write_property(self, name, val, outfile, tabs):
            if name == 'choices':
                xrc_write_choices_property(self, outfile, tabs)
            else:
                xrcgen.DefaultXrcObject.write_property(self, name, val,
                                                       outfile, tabs)

    # end of class ComboBoxXrcObject

    return ComboBoxXrcObject(obj)


class CppCodeGenerator:
    def get_code(self, obj):
        """\
        generates the C++ code for wxComboBox objects
        """
        cppgen = common.code_writers['C++']
        prop = obj.properties
        id_name, id = cppgen.generate_code_id(obj)
        if id_name: ids = [ id_name ]
        else: ids = []
        choices = prop.get('choices', [])
        if not obj.parent.is_toplevel: parent = '%s' % obj.parent.name
        else: parent = 'this'
        number = len(choices)
        ch_arr = '{\n        %s\n    };\n' % \
                 ',\n        '.join([cppgen.quote_str(c) for c in choices])
        style = prop.get("style")
        if not style: style = 'wxCB_DROPDOWN'
        else: style = 'wxCB_DROPDOWN|' + style
        init = []
        if number:
            init.append('const wxString %s_choices[] = %s' % (obj.name, ch_arr))
        else:
            init.append('const wxString *%s_choices = NULL;\n' % obj.name)
        init.append('%s = new %s(%s, %s, wxT(""), wxDefaultPosition, '
                    'wxDefaultSize, %s, %s_choices, %s);\n' % \
                    (obj.name, obj.klass, parent, id, number, obj.name, style))
        props_buf = cppgen.generate_common_properties(obj)
        selection = prop.get('selection')
        if selection is not None and len(prop.get('choices', [])):
            props_buf.append('%s->SetSelection(%s);\n' % (obj.name, selection))
        return init, ids, props_buf, []

# end of class CppCodeGenerator


def initialize():
    common.class_names['EditComboBox'] = 'wxComboBox'

    pygen = common.code_writers.get("python")
    if pygen:
        pygen.add_widget_handler('wxComboBox', PythonCodeGenerator())
        pygen.add_property_handler('choices', ChoicesCodeHandler)
    xrcgen = common.code_writers.get("XRC")
    if xrcgen:
        xrcgen.add_widget_handler('wxComboBox', xrc_code_generator)
        xrcgen.add_property_handler('choices', ChoicesCodeHandler)
    cppgen = common.code_writers.get('C++')
    if cppgen:
        cppgen.add_widget_handler('wxComboBox', CppCodeGenerator())
        cppgen.add_property_handler('choices', ChoicesCodeHandler)