Converting Pre-5.0 Leo files?

79 views
Skip to first unread message

Thomas Passin

unread,
Apr 22, 2020, 5:31:45 PM4/22/20
to leo-editor
I have some old, from version 4, Leo outlines.  They won't open in Leo these days.  I used to have a copy of Leo 4.7 that I could use, but I can't install that on my new computer because it wants PyQt4 and I can't get that for Python 2.7 any more (I keep a Python 2.7 installation just in case I need some package that hasn't been updated to Python 3).

Is there a practical way I can convert these old Leo files?  I suppose they may be so old that they won't be of much use, but I'd like to look back and see how I tried doing certain things.

Edward K. Ream

unread,
Apr 23, 2020, 6:35:54 AM4/23/20
to leo-editor
On Wed, Apr 22, 2020 at 4:31 PM Thomas Passin <tbp1...@gmail.com> wrote:

Is there a practical way I can convert these old Leo files? 

Not unless you can install Leo 4.7, but there should be a way.

Please send one of the files to me. I'll see if I can create a conversion script.

Edward

Thomas Passin

unread,
Apr 23, 2020, 8:39:33 AM4/23/20
to leo-editor
Here's one that won't open.  It raises scripting errors as it tries.
rasmas_development.leo

Edward K. Ream

unread,
Apr 23, 2020, 1:28:08 PM4/23/20
to leo-editor
On Thu, Apr 23, 2020 at 7:39 AM Thomas Passin <tbp1...@gmail.com> wrote:

> Here's one that won't open.  It raises scripting errors as it tries.

Please try reading the file in the "old" branch. An amazingly small change apparently recovers all the data, but likely not clone links.

Let me know if you have problems with other files, or if data gets dropped.

Edward

Edward K. Ream

unread,
Apr 23, 2020, 1:39:42 PM4/23/20
to leo-editor
On Thursday, April 23, 2020 at 12:28:08 PM UTC-5, Edward K. Ream wrote:

An amazingly small change apparently recovers all the data, but likely not clone links.

May still be true. However, in the file you sent, the missing "T" attributes look like they correspond to empty text, so it looks like (the new) Leo does indeed import everything.

Edward

Thomas Passin

unread,
Apr 23, 2020, 2:45:30 PM4/23/20
to leo-editor
I was able to read the file and recover the intended structure.  And I saved and re-opened it successfully.  However, after I saved the outline, it would not open in the devel branch version.  Here's the (last part of the) error I got:

  File "d:\Tom\git\leo-editor\leo\core\leoFileCommands.py", line 362, in scanVnodes
    v_element_visitor(v_elements, hidden_v)

  File "d:\Tom\git\leo-editor\leo\core\leoFileCommands.py", line 294, in v_element_visitor
    gnx = e.attrib['t']

KeyError: 't'

Thomas Passin

unread,
Apr 23, 2020, 2:52:26 PM4/23/20
to leo-editor
Here's another one of the old files.  The current "old" branch won't open this one at all.  Here's the last part of the error message:

  File "d:\Tom\git\leo-editor\leo\core\leoAtFile.py", line 536, in readFileAtPosition
    at.read(p, force=force)

  File "d:\Tom\git\leo-editor\leo\core\leoAtFile.py", line 366, in read
    FastAtRead(c, gnx2vnode).read_into_root(contents, fileName, root)

  File "d:\Tom\git\leo-editor\leo\core\leoAtFile.py", line 3726, in read_into_root
    self.scan_lines(delims, first_lines, lines, path, start_i)

  File "d:\Tom\git\leo-editor\leo\core\leoAtFile.py", line 3398, in scan_lines
    gnx, indent, body = stack.pop()

IndexError: pop from empty list

It fails before the menu bar gets displayed.
lsa.leo

Edward K. Ream

unread,
Apr 23, 2020, 3:18:16 PM4/23/20
to leo-editor
On Thu, Apr 23, 2020 at 1:45 PM Thomas Passin <tbp1...@gmail.com> wrote:
I was able to read the file and recover the intended structure.  And I saved and re-opened it successfully.  However, after I saved the outline, it would not open in the devel branch version. 

That's expected, I think. It's the same crash as before, so you must be in the "old" branch to re-read the .leo file.

The following will complete the conversion, as I have just verified:

- Open the file in "old".
- Copy the entire outline, then paste it back to the .leo file, then delete the old outline.
- Save the .leo file.
- Switch to "devel".

You should then be able to open the converted outline.

You should be able to complete the conversion by copying the entire outline, then pasting it, then deleting the old outline. After saving the file, you should then be able to read the file in devel.

Edward

Edward K. Ream

unread,
Apr 23, 2020, 3:22:17 PM4/23/20
to leo-editor
On Thu, Apr 23, 2020 at 1:52 PM Thomas Passin <tbp1...@gmail.com> wrote:
Here's another one of the old files. 

Please send the external file. I need the external file to be able to see the crash. Without it, the .leo file loads, with lots of "recovered nodes".

Edward

Thomas Passin

unread,
Apr 23, 2020, 3:47:45 PM4/23/20
to leo-editor
Here 'tis.
lsa.py

Thomas Passin

unread,
Apr 23, 2020, 4:19:05 PM4/23/20
to leo-editor
I tried to open the outline again, starting with copies restored from my backup drive.  This time, in "old", the outline opens but there is no content in the @file node.  I see no errors in the log pane or console.  I'm at a loss this time!

Leo 6.3-devel, old branch, build da026a477c
2020-04-23 12:41:01 -0500
Python 3.8.0, PyQt version 5.12.7
Windows 10 AMD64 (build 10.0.18362) SP0

Edward K. Ream

unread,
Apr 24, 2020, 7:26:35 AM4/24/20
to leo-editor
On Thu, Apr 23, 2020 at 3:19 PM Thomas Passin <tbp1...@gmail.com> wrote:

I tried to open the outline again, starting with copies restored from my backup drive.  This time, in "old", the outline opens but there is no content in the @file node.  I see no errors in the log pane or console.  I'm at a loss this time!

There is no way Leo can read old external files, and I have no plans to do so.

Instead, I'm working on a script that will convert old-style external files to outlines. This should allow you to recover all data in the external file, with perhaps a few minor differences regarding whitespace and Leo directives. A first draft is working, but it needs a rewrite. I hope to have something to show later today.

In short, recovering old .leo files will be done in two steps: recovering the data in the outline itself, and recovering the data in all external files.

Edward

Edward K. Ream

unread,
Apr 24, 2020, 2:45:48 PM4/24/20
to leo-editor
On Friday, April 24, 2020 at 6:26:35 AM UTC-5, Edward K. Ream wrote:

The second comment of #1581 now contains a script to recover ancient external files. Thomas, please test it and report any problems.

Next, I'll repackage the code into a LegacyFileReader class and one or more Leo commands based on that class. I'll do the work in devel, after merging the "old" branch in devel. It will probably happen tomorrow.

Edward

Edward K. Ream

unread,
Apr 24, 2020, 5:01:39 PM4/24/20
to leo-editor
On Friday, April 24, 2020 at 1:45:48 PM UTC-5, Edward K. Ream wrote:

> Next, I'll repackage the code into a [LegacyExternalFileImporter] class and one or more Leo commands based on that class.

Done at rev bcd329d in devel. The 'import-legacy-external-files' command prompts for one or more (python) files. Scripts may use the LegacyExternalFileImporter class directly if desired.

Still to do:

- Make sure that each file is actually a legacy external file.
- Support languages other than python.

Edward

Edward K. Ream

unread,
Apr 24, 2020, 5:38:12 PM4/24/20
to leo-editor
On Friday, April 24, 2020 at 4:01:39 PM UTC-5, Edward K. Ream wrote:
 
The 'import-legacy-external-files' command prompts for one or more (python) files...


Still to do:

- Make sure that each file is actually a legacy external file.
- Support languages other than python.

Done at rev 50b711 in devel. I'll leave #1581 open while testing continues.

Edward

Thomas Passin

unread,
Apr 24, 2020, 10:28:00 PM4/24/20
to leo-editor
Glory Be!  The external Python file I sent you imported like a charm.  Cruising through it, it seems to be in order.  Thanks!

Edward K. Ream

unread,
Apr 25, 2020, 6:39:48 AM4/25/20
to leo-editor
On Fri, Apr 24, 2020 at 9:28 PM Thomas Passin <tbp1...@gmail.com> wrote:

Glory Be!  The external Python file I sent you imported like a charm.  Cruising through it, it seems to be in order.  Thanks!

You're welcome. Thanks for the confirmation. I'll close #1581 when the import code handles section references.

Edward
Reply all
Reply to author
Forward
0 new messages