This file is indexed.

/usr/share/pyshared/mx/Proxy/Proxy.py is in python-egenix-mxproxy 3.2.1-1.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
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
""" Python part of the Proxy type implementation.

    Copyright (c) 2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
    Copyright (c) 2000-2011, eGenix.com Software GmbH; mailto:info@egenix.com
    See the documentation for further information on copyrights,
    or contact the author. All Rights Reserved.

"""
import types

# Import C extension module & register finalizer
from mxProxy import *
from mxProxy import __version__
try:
    finalizeweakrefs
except NameError:
    pass
else:
    class _ModuleFinalization:
        def __init__(self,function):
            self.fini = function
        def __del__(self):
            self.fini()
    _fini = _ModuleFinalization(finalizeweakrefs)

# Note: The type Proxy is defined in the C extension

try:
    from mx.Tools import freeze
except:
    freeze = lambda x: x

class ProxyFactory:

    """ Factory for producing Proxy-wrapped objects
        of a class.
    """
    def __init__(self,Class,interface=None):

        self.Class = Class
        self.interface = interface

    def __call__(self,*args,**kw):

        """ Return a new (wrapped) object. Pass-objects are not supported.
        """
        return Proxy(apply(self.Class,args,kw),self.interface)

    def __repr__(self):

        return '<ProxyFactory for %s>' % repr(self.Class)

class InstanceProxy:

    """ Proxy that wraps Python instances transparently.
    """
    def __init__(self,object,interface=None,passobj=None,

                 Proxy=Proxy):

        """ The interface is the same as that of the underlying C
            Proxy type.
        """
        dict = self.__dict__
        p = Proxy(object,interface,passobj)
        dict['proxy_getattr'] = p.proxy_getattr
        dict['proxy_setattr'] = p.proxy_setattr
        dict['proxy_object_repr'] = (object.__class__.__module__ + '.' +
                                     object.__class__.__name__)

    def __repr__(self):

        return '<%s.%s for %s at 0x%x>' % ( 
            self.__class__.__module__,
            self.__class__.__name__, 
            self.proxy_object_repr, 
            id(self))

    #
    # XXX Use specialized unbound C methods for these... trading a Python call
    #     against a dict lookup.
    #

    def __getattr__(self,what):
        return self.proxy_getattr(what)

    def __setattr__(self,what,to):
        self.proxy_setattr(what,to)

freeze(InstanceProxy)

class CachingInstanceProxy(InstanceProxy):

    """ Proxy that wraps Python instances transparently and caches
        accessed attributes and methods.

        Note that cached attributes are not looked up in the wrapped
        instance after the first lookup -- if their value changes,
        this won't be noticed by objects that access the object
        through this wrapper.

    """
    def __getattr__(self,what):

        self.__dict__[what] = o = self.proxy_getattr(what)
        return o

    def __setattr__(self,what,to):
        
        self.proxy_setattr(what,to)
        # Delete the cached entry...
        if self.__dict__.has_key(what):
            del self.__dict__[what]

freeze(CachingInstanceProxy)

class SelectiveCachingInstanceProxy(InstanceProxy):

    """ Proxy that wraps Python instances transparently and caches
        accessed attributes and methods depending on their type.

        Cached types are set via the attribute proxy_cacheable_types.
        It defaults to caching only methods (which likely don't change).

    """
    proxy_cacheable_types = (types.MethodType,)

    def __getattr__(self,what):

        o = self.proxy_getattr(what)
        if type(o) in self.proxy_cacheable_types:
            self.__dict__[what] = o
        return o

freeze(SelectiveCachingInstanceProxy)

# Alias
MethodCachingProxy = SelectiveCachingInstanceProxy

class InstanceProxyFactory:

    """ Factory for producing InstanceProxy-wrapped objects
        of a class.
    """
    def __init__(self,Class,interface=None):

        self.Class = Class
        self.interface = interface

    def __call__(self,*args,**kw):

        """ Return a new (wrapped) object. Pass-objects are not supported.
        """
        return InstanceProxy(apply(self.Class,args,kw),self.interface)

    def __repr__(self):

        return '<InstanceProxyFactory for %s>' % repr(self.Class)

class ReadonlyInstanceProxy(InstanceProxy):

    """ Proxy that wraps Python instances transparently in a read-only
        way.

    """
    def __init__(self,object,interface=None,passobj=None,

                 Proxy=Proxy):

        """ The interface is the same as that of the underlying C
            Proxy type.
        """
        dict = self.__dict__
        p = Proxy(object,interface,passobj)
        dict['proxy_getattr'] = p.proxy_getattr
        dict['proxy_object_repr'] = (object.__class__.__module__ + '.' +
                                     object.__class__.__name__)

    def __setattr__(self,what,to):
        raise AccessError,'write access denied'

freeze(ReadonlyInstanceProxy)

### Experimental:

class _Link:

    """ Proxy that links to an instance attribute in another object.

        XXX Should convert special lookups like __len__ to
            PyObject_* calls (for non-instance attributes).

    """
    def __init__(self,object,attrname):

        """ The interface is the same as that of the underlying C
            Proxy type.
        """
        dict = self.__dict__
        dict['proxy_object'] = object
        dict['proxy_attrname'] = attrname

    def __getattr__(self,what):
        return getattr(getattr(self.proxy_object,self.proxy_attrname),what)

    def __setattr__(self,what,to):
        setattr(getattr(self.proxy_object,self.proxy_attrname),what,to)