On Monday, April 13, 2015 at 10:08:29 AM UTC-5, Edward K. Ream wrote:
*> Soon*: an @button script that warns if leoProjects.txt or leoToDo.txt
contains clones.
Here it is:
'''Warn if leoProjects.txt or leoToDo.txt contain any clones.'''
clones,nodes,seen = 0,0,set()
table = (
'@file ../doc/leoProjects.txt',
'@file ../doc/leoToDo.txt',
)
def check_clone(c,p0,root):
'''Warn if p appears in any @<file> node outside of root's tree.'''
global nodes,seen
v = p0.v
for p in c.all_positions():
nodes += 1
if p.v == v:
# Check *all* ancestors, not just the nearest one.
for parent in p.self_and_parents():
nodes += 1
if parent.isAnyAtFileNode() and parent.v != root.v:
if parent.v not in seen:
seen.add(parent.v)
g.es_print('%s and %s contain clone: %s' % (
root.h,parent.h,p0.h))
for h in table:
root = g.findNodeAnywhere(c,h)
if root:
for p in root.self_and_subtree():
nodes += 1
if p.isCloned():
clones += 1
check_clone(c,p,root)
else:
g.es_print('not found',h,color='red')
print('done: %s nodes, %s clones' % (nodes,clones))
@tabwidth -4
@language python
EKR
--
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 http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.