On Sun, 14 May 2017 14:15:25 -0700
Lang Hurst <[email protected]> wrote:
> I have two nodes that I run a `diff -y` on and use the results in a
> document. It would be cool to be able to include the node in my
> document outline and have the results of the command show up and skip
> a couple manual steps, or really setting up some inodify trigger.
> Does that make sense? Spent the weekend playing around with Leo and
> am pretty sold on it right now.
>
> -Lang
>
> If this helps:
>
> - @rst-ignore Node with some information
> - @rst-gnore Node with different info
> - node that contains the diff of the previous two nodes
Hmm, didn't read your question carefully enough. So answer using
external diff program on external files:
# this script, when executed in a node
from subprocess import Popen, PIPE
cmd = Popen(['diff', 'this', 'that'], stdin=PIPE, stderr=PIPE)
p.b += "%s\n%s" % cmd.communicate()
c.redraw()
# appends this text to that node, 'None' being stdout, and the errors being
stderr.
None
diff: this: No such file or directory
diff: that: No such file or directory
But to diff the two previous nodes:
p0 = p.copy().moveToThreadBack() # prev node
p1 = p0.copy().moveToThreadBack() # prev prev node
import difflib
p.b += '\n'.join(difflib.unified_diff(
p1.b.split('\n'), p0.b.split('\n'), fromfile='prev.prev', tofile='prev'))
c.redraw()
Cheers -Terry
--
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.