[Script] Dictionary to Leo outline

28 views
Skip to first unread message

Fidel N

unread,
Aug 23, 2014, 1:56:29 PM8/23/14
to leo-e...@googlegroups.com
Hi:
When working with a dictionary, some times I really need to "see it", so I needed this small script.
It will transform a dictionary into an outline, so you can navigate through it.
Just in case its useful for anyone, here it goes:

def dictionary_to_outline(p,dictionary):


    '''

    Transform a dictionary into the subtree outline of the given position

    '''


    g.app.gui.frameFactory.masterFrame.currentWidget().leo_c


    sorted_keys = sorted([key for key in dictionary])


    for key in sorted_keys:


        new_node = p.insertAsLastChild().copy()


        new_node.h = key


        if "dict" in str(type(dictionary[key])):


            self.dictionary_to_outline(new_node,dictionary[key])


        else:


            new_node.b = str(dictionary[key])


Edward K. Ream

unread,
Sep 10, 2014, 7:52:09 PM9/10/14
to leo-editor
On Sat, Aug 23, 2014 at 12:56 PM, Fidel N <fidel...@gmail.com> wrote:
> Hi:
> When working with a dictionary, some times I really need to "see it", so I
> needed this small script.

Nice. I've put this in the to-be-documented bin ;-)

Edward
Reply all
Reply to author
Forward
0 new messages