Someday I hope to be able to use Leo to manage some fairly large and complex projects, specifically with the use of clones, and I would be looking for a way to import project data elements into Leo. I was envisioning using Leo's ability to import MORE format files, since it is such a simple format (and being a Leo newbie, I like simple!).

MORE uses + and - to trigger new headlines, and I was envisioning a new, special character to trigger the creation of a cloned node at the current import location. Suppose the special character is a tilde (~).

+ someheadline1
Body text for someheadline1 goes here.
+ someheadline2
Body text for someheadline2 goes here.
+ someheadline3
Body text for someheadline3 goes here.
+ project element1
Body text for project element1 goes here.
  -~ someheadline2
+ project element2
Body text for project element2 goes here.
  -~ someheadline1
  -~ someheadline2
+~ someheadline3

There could be no body text below a headline marked with "~" as the body would come from the cloned node.

What I think I'd have to do in leoImport.py is:

1. Change moreHeadlineLevel() to look for "~" in addition to "+" and "-"

2. Probably change moreHeadlineLevel() to return a new flag, maybe cloneFlag, when it found a "~".

3. Change convertMoreStringsToOutlineAfter() so that after moreHeadlineLevel(), if cloneFlag is true...

4. Call findTopLevelNode() with the text of the "~" headline, and if one is found...

... and this is as far as I think I can code on my own. What are the equivalents to insertAfter() and insertAsNthChild() when inserting as clones? Is there anything else I would need to do to implement the logic above?

Do I know what I'm doing? No. Do I know Python? No. But I can study the code to try to figure things out as best I can. Then holler for help on this forum. :D

-------- Original Message --------
Subject: Re: Creating outline file programmatically - any samples?
From: Edward K. Ream <[email protected]>
To: [email protected]
Date: Tuesday, December 14, 2010 7:33:04 AM

On Tue, Dec 14, 2010 at 7:21 AM, Satheesh Babu Vattekkat
<[email protected]>  wrote:
One really good use I can
think of is to automate generating outline files from different data
sources.

ie., take a minimal file, load it into Leo, then run through my
exported data and attach instances of leoNodes to the file and then
save it. I will also need to attach cloned nodes at various points in
the outline.

Has anyone done this or any pointers on how to go about this?

Creating a new Leo outline will create a minimal .leo file when you
save the outline.

A script can do this with c2 = c.new()

If you don't want to see the new window, you can use the contents of
c.new to guide you. c.new calls::

   c,frame = g.app.newLeoCommanderAndFrame(
         fileName=yourFileName,gui=None)

If gui is None, g.app.gui is used as default.  We may want a null gui::

import leo.core.leoGui as leoGui
nullGui = leoGui.nullGui("nullGui")
c2,frame = g.app.newLeoCommanderAndFrame(
         fileName=None,gui=nullGui)
c2.frame.createFirstTreeNode()
for p in c2.all_positions():
     g.es(p.h)

This works.

Edward


--
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to