##// END OF EJS Templates
ipy_leo: LeoNode.uA for unknownAttributes
Ville M. Vainio -
Show More
@@ -96,8 +96,8 b' class LeoNode(object, UserDict.DictMixin):'
96 96 def __init__(self,p):
97 97 self.p = p.copy()
98 98
99 def get_h(self): return self.p.headString()
100 def set_h(self,val):
99 def __get_h(self): return self.p.headString()
100 def __set_h(self,val):
101 101 print "set head",val
102 102 c.beginUpdate()
103 103 try:
@@ -105,10 +105,10 b' class LeoNode(object, UserDict.DictMixin):'
105 105 finally:
106 106 c.endUpdate()
107 107
108 h = property( get_h, set_h, doc = "Node headline string")
108 h = property( __get_h, __set_h, doc = "Node headline string")
109 109
110 def get_b(self): return self.p.bodyString()
111 def set_b(self,val):
110 def __get_b(self): return self.p.bodyString()
111 def __set_b(self,val):
112 112 print "set body",val
113 113 c.beginUpdate()
114 114 try:
@@ -116,24 +116,24 b' class LeoNode(object, UserDict.DictMixin):'
116 116 finally:
117 117 c.endUpdate()
118 118
119 b = property(get_b, set_b, doc = "Nody body string")
119 b = property(__get_b, __set_b, doc = "Nody body string")
120 120
121 def set_val(self, val):
121 def __set_val(self, val):
122 122 self.b = format_for_leo(val)
123 123
124 v = property(lambda self: eval_node(self), set_val, doc = "Node evaluated value")
124 v = property(lambda self: eval_node(self), __set_val, doc = "Node evaluated value")
125 125
126 def set_l(self,val):
126 def __set_l(self,val):
127 127 self.b = '\n'.join(val )
128 128 l = property(lambda self : IPython.genutils.SList(self.b.splitlines()),
129 set_l, doc = "Node value as string list")
129 __set_l, doc = "Node value as string list")
130 130
131 131 def __iter__(self):
132 132 """ Iterate through nodes direct children """
133 133
134 134 return (LeoNode(p) for p in self.p.children_iter())
135 135
136 def _children(self):
136 def __children(self):
137 137 d = {}
138 138 for child in self:
139 139 head = child.h
@@ -147,7 +147,7 b' class LeoNode(object, UserDict.DictMixin):'
147 147 continue
148 148 return d
149 149 def keys(self):
150 d = self._children()
150 d = self.__children()
151 151 return d.keys()
152 152 def __getitem__(self, key):
153 153 """ wb.foo['Some stuff'] Return a child node with headline 'Some stuff'
@@ -155,7 +155,7 b' class LeoNode(object, UserDict.DictMixin):'
155 155 If key is a valid python name (e.g. 'foo'), look for headline '@k foo' as well
156 156 """
157 157 key = str(key)
158 d = self._children()
158 d = self.__children()
159 159 return d[key]
160 160 def __setitem__(self, key, val):
161 161 """ You can do wb.foo['My Stuff'] = 12 to create children
@@ -171,7 +171,7 b' class LeoNode(object, UserDict.DictMixin):'
171 171 and we don't want to crowd the WorkBook namespace with (possibly numerous) entries
172 172 """
173 173 key = str(key)
174 d = self._children()
174 d = self.__children()
175 175 if key in d:
176 176 d[key].v = val
177 177 return
@@ -193,9 +193,17 b' class LeoNode(object, UserDict.DictMixin):'
193 193 try:
194 194 c.setCurrentPosition(self.p)
195 195 finally:
196 c.endUpdate()
196 c.endUpdate()
197 197
198 def __get_uA(self):
199 p = self.p
200 # Create the uA if necessary.
201 if not hasattr(p.v.t,'unknownAttributes'):
202 p.v.t.unknownAttributes = {}
198 203
204 d = p.v.t.unknownAttributes.setdefault('ipython', {})
205 return d
206 uA = property(__get_uA, doc = "Access persistent unknownAttributes of node'")
199 207
200 208
201 209 class LeoWorkbook:
General Comments 0
You need to be logged in to leave comments. Login now