Identity a node, read it's data

68 views
Skip to first unread message

lewis

unread,
Aug 22, 2019, 7:02:11 AM8/22/19
to leo-editor
Leo docs describe Global Node Index (gnx) as giving each node a unique, immutable identity.

I have a few questions.
1. How do you find the gnx identity of a node?
2. Once you know the gnx of a node, can a script be directed to read the data in that node?

I get the impression gnx's are related to external files, or clones. Whereas I am looking for a simple way to identify a node and read it's data.

Thanks
Lewis

vitalije

unread,
Aug 22, 2019, 8:25:24 AM8/22/19
to leo-editor


On Thursday, August 22, 2019 at 1:02:11 PM UTC+2, lewis wrote:
Leo docs describe Global Node Index (gnx) as giving each node a unique, immutable identity.

I have a few questions.
1. How do you find the gnx identity of a node?

Using p.v.gnx (or p.v.fileIndex it used to be old name of this attribute).

 
2. Once you know the gnx of a node, can a script be directed to read the data in that node?


If you have gnx and wish to know headline or body, you can get corresponding v node using:

v = c.fileCommands.gnxDict.get(gnx)
v.h is headline, v.b is body.

I get the impression gnx's are related to external files, or clones. Whereas I am looking for a simple way to identify a node and read it's data.


Yes in the external files gnxes are written inside sentinel comments. Without them written in the external files, clones would loose their clone-yness and become unrelated nodes.

HTH Vitalije

lewis

unread,
Aug 22, 2019, 8:52:19 AM8/22/19
to leo-editor
Thanks Vitalije, I'll try and apply that to what I would like to do :)

For example say I have 3 nodes in a leo file:

node_A (containing data e.g. CSV)
node_B
node_C

I would like to write:
script in node_B to edit/write data in node_A
script in node_C to analyse and report on the data in node_A

Regards
Lewis

Edward K. Ream

unread,
Aug 22, 2019, 10:28:09 AM8/22/19
to leo-editor
On Thu, Aug 22, 2019 at 7:25 AM vitalije <vita...@gmail.com> wrote:

Using p.v.gnx (or p.v.fileIndex it used to be old name of this attribute).

v.gnx is a python property, which resolves to v.fileIndex, a real ivar.  Properties are much slower than ivars, but usually that doesn't matter.  It's best just to use the simpler property.  Leo uses v.fileIndex during startup because its faster.  When in doubt, use v.gnx, not v.fileIndex.

Edward
Reply all
Reply to author
Forward
0 new messages