Show More
@@ -96,8 +96,8 b' class LeoNode(object, UserDict.DictMixin):' | |||||
96 | def __init__(self,p): |
|
96 | def __init__(self,p): | |
97 | self.p = p.copy() |
|
97 | self.p = p.copy() | |
98 |
|
98 | |||
99 | def get_h(self): return self.p.headString() |
|
99 | def __get_h(self): return self.p.headString() | |
100 | def set_h(self,val): |
|
100 | def __set_h(self,val): | |
101 | print "set head",val |
|
101 | print "set head",val | |
102 | c.beginUpdate() |
|
102 | c.beginUpdate() | |
103 | try: |
|
103 | try: | |
@@ -105,10 +105,10 b' class LeoNode(object, UserDict.DictMixin):' | |||||
105 | finally: |
|
105 | finally: | |
106 | c.endUpdate() |
|
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() |
|
110 | def __get_b(self): return self.p.bodyString() | |
111 | def set_b(self,val): |
|
111 | def __set_b(self,val): | |
112 | print "set body",val |
|
112 | print "set body",val | |
113 | c.beginUpdate() |
|
113 | c.beginUpdate() | |
114 | try: |
|
114 | try: | |
@@ -116,24 +116,24 b' class LeoNode(object, UserDict.DictMixin):' | |||||
116 | finally: |
|
116 | finally: | |
117 | c.endUpdate() |
|
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 | self.b = format_for_leo(val) |
|
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 | self.b = '\n'.join(val ) |
|
127 | self.b = '\n'.join(val ) | |
128 | l = property(lambda self : IPython.genutils.SList(self.b.splitlines()), |
|
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 | def __iter__(self): |
|
131 | def __iter__(self): | |
132 | """ Iterate through nodes direct children """ |
|
132 | """ Iterate through nodes direct children """ | |
133 |
|
133 | |||
134 | return (LeoNode(p) for p in self.p.children_iter()) |
|
134 | return (LeoNode(p) for p in self.p.children_iter()) | |
135 |
|
135 | |||
136 | def _children(self): |
|
136 | def __children(self): | |
137 | d = {} |
|
137 | d = {} | |
138 | for child in self: |
|
138 | for child in self: | |
139 | head = child.h |
|
139 | head = child.h | |
@@ -147,7 +147,7 b' class LeoNode(object, UserDict.DictMixin):' | |||||
147 | continue |
|
147 | continue | |
148 | return d |
|
148 | return d | |
149 | def keys(self): |
|
149 | def keys(self): | |
150 | d = self._children() |
|
150 | d = self.__children() | |
151 | return d.keys() |
|
151 | return d.keys() | |
152 | def __getitem__(self, key): |
|
152 | def __getitem__(self, key): | |
153 | """ wb.foo['Some stuff'] Return a child node with headline 'Some stuff' |
|
153 | """ wb.foo['Some stuff'] Return a child node with headline 'Some stuff' | |
@@ -155,7 +155,7 b' class LeoNode(object, UserDict.DictMixin):' | |||||
155 | If key is a valid python name (e.g. 'foo'), look for headline '@k foo' as well |
|
155 | If key is a valid python name (e.g. 'foo'), look for headline '@k foo' as well | |
156 | """ |
|
156 | """ | |
157 | key = str(key) |
|
157 | key = str(key) | |
158 | d = self._children() |
|
158 | d = self.__children() | |
159 | return d[key] |
|
159 | return d[key] | |
160 | def __setitem__(self, key, val): |
|
160 | def __setitem__(self, key, val): | |
161 | """ You can do wb.foo['My Stuff'] = 12 to create children |
|
161 | """ You can do wb.foo['My Stuff'] = 12 to create children | |
@@ -171,7 +171,7 b' class LeoNode(object, UserDict.DictMixin):' | |||||
171 | and we don't want to crowd the WorkBook namespace with (possibly numerous) entries |
|
171 | and we don't want to crowd the WorkBook namespace with (possibly numerous) entries | |
172 | """ |
|
172 | """ | |
173 | key = str(key) |
|
173 | key = str(key) | |
174 | d = self._children() |
|
174 | d = self.__children() | |
175 | if key in d: |
|
175 | if key in d: | |
176 | d[key].v = val |
|
176 | d[key].v = val | |
177 | return |
|
177 | return | |
@@ -193,9 +193,17 b' class LeoNode(object, UserDict.DictMixin):' | |||||
193 | try: |
|
193 | try: | |
194 | c.setCurrentPosition(self.p) |
|
194 | c.setCurrentPosition(self.p) | |
195 | finally: |
|
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 | class LeoWorkbook: |
|
209 | class LeoWorkbook: |
General Comments 0
You need to be logged in to leave comments.
Login now