This file is indexed.

/usr/lib/python2.7/dist-packages/PythonCard/tools/resourceEditor/modules/resourceOutput.py is in python-pythoncard 0.8.2-5.

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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
"""
__version__ = "$Revision: 1.34 $"
__date__ = "$Date: 2006/03/03 10:07:21 $"
"""

import wx

SPACES = '    '

def colorDescription(color):
    if isinstance(color, str):
        return "'%s'" % color
    else:
        return "%s" % str(color)

# this is a complete hack job in order to avoid
# outputting defaults
def widgetAttributes(background, aWidget):
    # this might be overly aggressive
    # it could be that the normal default of white might be different on these
    # various widgets rather than being the same, so the wxTextCtrl is
    # not a good comparison
    flds = ['TextField', 'PasswordField', 'TextArea']
    txtWidgets = ['TextField', 'PasswordField', 'TextArea', 'Choice',
                  'List', 'Calendar', 'ComboBox']
    imgWidgets = ['Image', 'ImageButton']
    comp = background.propertyEditorWindow.components
    dFgC = comp.wUpdate.foregroundColor.Get()
    dBgC = comp.wUpdate.backgroundColor.Get()
    dFont = repr(comp.wUpdate.font)
    dTextBgC = comp.wField.backgroundColor.Get()
    
    # make sure these primary attributes show up
    # at the beginning of the listing
    # the remaining ones will be in alphabetical order
    dStr = "{'type':'%s', \n" % aWidget.__class__.__name__
    
    # KEA 2002-03-24
    # only save the special ids
    if background.editingDialog and aWidget.__class__.__name__ == 'Button':
        if aWidget.id in [wx.ID_OK, wx.ID_CANCEL, wx.ID_YES, wx.ID_NO]:
            dStr += "    'id':%d, \n" % aWidget.id            

    dStr += "    'name':'%s', \n" % aWidget.name
    dStr += "    'position':%s, \n" % str(aWidget.position)

    # try and determine default sizes        
    width, height = aWidget.size
    if aWidget.__class__.__name__ in imgWidgets:
        width, height = aWidget._size
    elif aWidget.__class__.__name__ not in ['BitmapCanvas', 'HtmlWindow', 'IEHtmlWindow', 'Gauge', 'StaticBox', 'FloatCanvas']:
        bestWidth, bestHeight = aWidget.GetBestSize()
        if bestWidth == width:
            width = -1
        if bestHeight == height:
            height = -1
    if width != -1 or height != -1:
        dStr += "    'size':(%d, %d), \n" % (width, height)

        
    #for key in aWidget._getAttributeNames():
    attributes = aWidget._spec.getAttributes().keys()
    attributes.sort()
    for key in attributes:
        if key in ['id', 'bitmap', 'name', 'position', 'selection', 'size']:
            pass
        elif getattr(aWidget, key) is not None:
            #print aWidget.__class__.__name__, key, getattr(aWidget, key)
            value = getattr(aWidget, key)
            if key == 'file' and aWidget.__class__.__name__ in imgWidgets and value == '':
                dStr += "    'file':'', \n"
                continue

            if key == 'alignment' and \
                aWidget.__class__.__name__ in ['StaticText', 'PasswordField', 'TextField', 'TextArea'] \
                and value == 'left':
                continue
            if key == 'border' and aWidget.__class__.__name__ in txtWidgets and value == '3d':
                continue
            if key == 'backgroundColor' and \
               aWidget.__class__.__name__ in txtWidgets and \
               value.Get() == dTextBgC:
                continue
            if key == 'foregroundColor' and value.Get() == dFgC:
                continue
            if key == 'backgroundColor' and value.Get() == dBgC:
                continue
            if key == 'font' and repr(value) == dFont:
                continue
            if key == 'actionBindings' and value == {}:
                continue
            # KEA 2002-07-07
            # what other Unicode strings do we need to deal with above?
            #print key, value, type(value)
            if isinstance(value, (str, unicode)):
                # if isinstance(value, unicode):
                #     value = value.encode('ascii', 'ignore')
                # need to escape strings
                #pprint.pprint(value)
                if value != '':
                    dStr += """    %s:%s, \n""" % (repr(key), repr(value))
            else:
                if (key in ['editable', 'enabled', 'visible'] and value == True) or \
                    (key in ['checked', 'default', 'horizontalScrollbar'] and value == False):
                    # don't include default values
                    pass
                else:
                    dStr += "    '%s':%s, \n" % (key, value)
    dStr += '    },\n'
    return dStr


def resourceMenuItemAttributes(menuItem):
    desc =  SPACES * 4 + "  {'type':'MenuItem',\n"
    desc += SPACES * 4 + "   'name':'%s',\n" % menuItem.name
    desc += SPACES * 4 + """   'label':%s,\n""" % repr(menuItem.label)
    try:
        if menuItem.command is not None:
            desc += SPACES * 4 + "   'command':'%s',\n" % menuItem.command
    except:
        pass
    try:
        if not menuItem.enabled:
            desc += SPACES * 4 + "   'enabled':0,\n"
    except:
        pass
    try:
        if menuItem.checkable:
            desc += SPACES * 4 + "   'checkable':1,\n"
        if menuItem.checked:
            desc += SPACES * 4 + "   'checked':1,\n"
    except:
        pass
    desc += SPACES * 4 + "  },\n"
    return desc

def resourceMenuAttributes(menu):
    desc =  SPACES * 3 + " {'type':'Menu',\n"
    desc += SPACES * 3 + " 'name':'%s',\n" % menu.name
    desc += SPACES * 3 + """ 'label':%s,\n""" % repr(menu.label)
    desc += SPACES * 3 + " 'items': [\n"
    
    for m in menu.items:
        desc += resourceMenuItemAttributes(m)
        
    desc += SPACES * 3 + "  ]\n"
    desc += SPACES * 3 + " },\n"
    return desc

def resourceMenubarAttributes(menubar):
    desc =  SPACES * 2 + "'menubar': {'type':'MenuBar',\n"
    desc += SPACES * 2 + " 'menus': [\n"

    for m in menubar.menus:
        desc += resourceMenuAttributes(m)
    
    desc += SPACES * 2 + " ]\n"
    desc += SPACES + " },\n"
    return desc

def resourceBackgroundAttributes(background, bg):
    desc =  "    {'type':'Background',\n"
    desc += "          'name':'%s',\n" % bg.name
    desc += """          'title':%s,\n""" % repr(bg.title)
    # KEA 2004-10-04
    # need a more sophisticated way of specifying an optional position
    # but just saving the position the user is editing the window at
    # is bad, so turn it off for now
##    desc += "          'position':%s,\n" % str(background.GetPositionTuple())
    desc += "          'size':%s,\n" % str(background.GetSizeTuple())
    
    if bg.statusBar is not None and bg.statusBar:
        desc += "          'statusBar':1,\n"
    if bg.foregroundColor is not None:
        desc += "          'foregroundColor':" +  colorDescription(bg.foregroundColor) + ",\n"
    if bg.backgroundColor is not None:
        desc += "          'backgroundColor':" + colorDescription(bg.backgroundColor) + ",\n"
    if bg.icon is not None: 
        desc += "          'icon':'%s',\n" % bg.icon
    if bg.image is not None:
        desc += "          'image':'%s',\n" % bg.image
    if bg.tiled:
        desc += "          'tiled':1,\n"
    if not bg.visible:
        desc += "          'visible':0,\n"
    if bg.style != []:
        desc += "          'style':%s,\n" % str(bg.style)
    desc += "\n"

    try:
        desc += resourceMenubarAttributes(bg.menubar)
    except:
        pass

    # KEA 2002-05-15
    # strings
    if bg.strings != {}:
        desc += "         'strings': {\n"
        for s in bg.strings.__dict__:
            desc += """         %s:%s,\n""" % (repr(s), repr(bg.strings.__dict__[s]))
        desc += "         },\n\n"
    
    desc += "         'components': [\n\n"
    return desc

def resourceStackAttributes(background):
    if background.rsrc is None:
        print "no rsrc"
        # we should probably blow up here

    desc =  "{'application':{'type':'Application',\n"
    desc += "          'name':'%s',\n" % background.rsrc.application.name
    desc += "    'backgrounds': [\n"
    desc += resourceBackgroundAttributes(background, background.rsrc.application.backgrounds[0])
    
    return desc

def resourceDialogAttributes(background, bg):
    desc =  "{'type':'CustomDialog',\n"
    desc += "    'name':'%s',\n" % bg.name
    desc += "    'title':'%s',\n" % bg.title
    desc += "    'position':%s,\n" % str(background.GetPositionTuple())
    desc += "    'size':%s,\n" % str(background.GetSizeTuple())
    #if bg.statusBar is not None and bg.statusBar:
    #    desc += "          'statusBar':1,\n"
    #desc += "\n"
    #if bg.foregroundColor is not None:
    #    desc += "         'foregroundColor':" +  colorDescription(bg.foregroundColor) + ",\n"
    #if bg.backgroundColor is not None:
    #    desc += "         'backgroundColor':" + colorDescription(bg.backgroundColor) + ",\n"
    #if bg.image is not None:
    #    desc += "         'image':'%s',\n" % bg.image
    #if bg.tiled != 0:
    #    desc += "         'tiled':1,\n"

    # KEA 2002-09-12
    # strings
    if bg.strings != {}:
        desc += "\n    'strings': {\n"
        for s in bg.strings.__dict__:
            desc += """        %s:%s,\n""" % (repr(s), repr(bg.strings.__dict__[s]))
        desc += "    },\n\n"

    desc += "    'components': [\n\n"
    return desc

def resourceAttributes(background):
    # KEA 2002-03-24
    """
    editingDialog = 0
    try: 
        name = background.rsrc.application.name
    except:
        editingDialog = 1
    """

    if background.editingDialog:
        desc = resourceDialogAttributes(background, background.rsrc)
        for w in background.components.order:
            if w not in background.sizingHandleNames:
                desc += widgetAttributes(background, background.components[w]) + "\n"

        desc += "] # end components\n"
        desc += "} # end CustomDialog\n"
    else:
        desc = resourceStackAttributes(background)
        for w in background.components.order:
            if w not in background.sizingHandleNames:
                desc += widgetAttributes(background, background.components[w]) + "\n"

        desc += "] # end components\n"
        desc += "} # end background\n"
        desc += "] # end backgrounds\n"
        desc += "} }\n"
        
    return desc