For last few days I was experimenting with writing external files (at-file trees) and parsing those files to recreate tree. I have started this exploration looking for a better way to use new v.lines property. This is short report of what I have found so far.
Attached to this post is example .leo document which contains one documentation node and one dev script node. This script relies on being part of leo/core/LeoPyRef.leo so in order to see it in effect one should copy that script to personal LeoPyRef.leo. The only dependency on that outline is to have access to all leo/core/*.py files that are located in 'Core classes' node of LeoPyRef.leo. This script node contains both new read/write code and several tests to check correctness of new code. It also contains some profiling tests comparing normal Leo read code with the new code. Although new code showed some (very small) speed improvements (under 8%), it is not very important. More important is I believe code size difference. New code has less than 445 lines of code (* 445 including tests). For comparison: leoAtFile.py scriptFile.py 4221 code lines 445 code lines 909 comment lines 44 comment lines 79 empty lines 8 empty lines New code is not full replacement for leoAtFile.py. It just knows how to read python files generated with at-file code. However, I believe it won't be too hard to add missing features. Here is how I got all these features so far. I have started with reading and parsing one of the files and comparing with Leo outline. Whenever I encountered some differences I have adjusted code until finally there were no single difference while reading all Leo core python files. To complete implementation to fully support all of Leo features I need more example files, and I believe that it won't require much more code to fully support all Leo features. Edward, please have a look in this code. My intention is not to criticize your code in leoAtFile or to compete with you. leoAtFile certainly contains inside much more functionality than it is in this simple experiment. I made this experiment just to try and see how far it can get and I was surprised how easy it was to reach to this point and in such a small number of lines. Even if you had no intentions to change anything in leoAtFile because it is decades old and had proven to work correctly, maybe this experiment can give you some new ideas that can be used somewhere else in Leo code. All comments are welcome. Vitalije PS: this is example of using Edward's receipt for live development inside Leo. I created script-button of this dev node and because it had '@keys=Alt-4` in headline, this has bound Alt+4 key combination to executing code under development. -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
at-file-experiments.leo
Description: Binary data
