~ubuntu-branches/ubuntu/trusty/python3.4/trusty-proposed

« back to all changes in this revision

Viewing changes to Lib/idlelib/RemoteObjectBrowser.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-11-25 09:44:27 UTC
  • Revision ID: package-import@ubuntu.com-20131125094427-lzxj8ap5w01lmo7f
Tags: upstream-3.4~b1
ImportĀ upstreamĀ versionĀ 3.4~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from idlelib import rpc
 
2
 
 
3
def remote_object_tree_item(item):
 
4
    wrapper = WrappedObjectTreeItem(item)
 
5
    oid = id(wrapper)
 
6
    rpc.objecttable[oid] = wrapper
 
7
    return oid
 
8
 
 
9
class WrappedObjectTreeItem:
 
10
    # Lives in PYTHON subprocess
 
11
 
 
12
    def __init__(self, item):
 
13
        self.__item = item
 
14
 
 
15
    def __getattr__(self, name):
 
16
        value = getattr(self.__item, name)
 
17
        return value
 
18
 
 
19
    def _GetSubList(self):
 
20
        sub_list = self.__item._GetSubList()
 
21
        return list(map(remote_object_tree_item, sub_list))
 
22
 
 
23
class StubObjectTreeItem:
 
24
    # Lives in IDLE process
 
25
 
 
26
    def __init__(self, sockio, oid):
 
27
        self.sockio = sockio
 
28
        self.oid = oid
 
29
 
 
30
    def __getattr__(self, name):
 
31
        value = rpc.MethodProxy(self.sockio, self.oid, name)
 
32
        return value
 
33
 
 
34
    def _GetSubList(self):
 
35
        sub_list = self.sockio.remotecall(self.oid, "_GetSubList", (), {})
 
36
        return [StubObjectTreeItem(self.sockio, oid) for oid in sub_list]