Show More
@@ -187,12 +187,27 b' class LeoNode(object, UserDict.DictMixin):' | |||||
187 | def ipush(self): |
|
187 | def ipush(self): | |
188 | """ Does push-to-ipython on the node """ |
|
188 | """ Does push-to-ipython on the node """ | |
189 | push_from_leo(self) |
|
189 | push_from_leo(self) | |
|
190 | def go(self): | |||
|
191 | """ Set node as current node (to quickly see it in Outline) """ | |||
|
192 | c.beginUpdate() | |||
|
193 | try: | |||
|
194 | c.setCurrentPosition(self.p) | |||
|
195 | finally: | |||
|
196 | c.endUpdate() | |||
190 |
|
197 | |||
191 |
|
198 | |||
192 |
|
199 | |||
193 |
|
200 | |||
194 | class LeoWorkbook: |
|
201 | class LeoWorkbook: | |
195 |
""" class for 'advanced' node access |
|
202 | """ class for 'advanced' node access | |
|
203 | ||||
|
204 | Has attributes for all "discoverable" nodes. Node is discoverable if it | |||
|
205 | either | |||
|
206 | ||||
|
207 | - has a valid python name (Foo, bar_12) | |||
|
208 | - is a parent of an anchor node (if it has a child '@a foo', it is visible as foo) | |||
|
209 | ||||
|
210 | """ | |||
196 | def __getattr__(self, key): |
|
211 | def __getattr__(self, key): | |
197 | if key.startswith('_') or key == 'trait_names' or not valid_attribute(key): |
|
212 | if key.startswith('_') or key == 'trait_names' or not valid_attribute(key): | |
198 | raise AttributeError |
|
213 | raise AttributeError | |
@@ -209,6 +224,12 b' class LeoWorkbook:' | |||||
209 | raise AttributeError("Direct assignment to workbook denied, try wb.%s.v = %s" % (key,val)) |
|
224 | raise AttributeError("Direct assignment to workbook denied, try wb.%s.v = %s" % (key,val)) | |
210 |
|
225 | |||
211 | __repr__ = __str__ |
|
226 | __repr__ = __str__ | |
|
227 | ||||
|
228 | def __iter__(self): | |||
|
229 | """ Iterate all (even non-exposed) nodes """ | |||
|
230 | cells = all_cells() | |||
|
231 | return (LeoNode(p) for p in c.allNodes_iter()) | |||
|
232 | ||||
212 | ip.user_ns['wb'] = LeoWorkbook() |
|
233 | ip.user_ns['wb'] = LeoWorkbook() | |
213 |
|
234 | |||
214 |
|
235 |
General Comments 0
You need to be logged in to leave comments.
Login now