Here is the correct def for clean_file:
def clean_file(p):
at = c.atFileCommands
if hasattr(p.v.t,'tnodeList'):
has_list = True
old_list = p.v.t.tnodeList[:]
else:
has_list = False
at.write(
root=p,nosentinels=True,
thinFile=False,
scriptWrite=True,
toString=True,
write_strips_blank_lines=False)
if has_list:
p.v.t.tnodeList = old_list
fileName = g.os_path_normpath(
g.os_path_join(
at.default_directory,'clean',p.anyAtFileNodeName()))
# g.trace(p.headString(),len(at.stringOutput),fileName)
# Adapted from at.openFileForWritingHelper
path = g.os_path_dirname(fileName)
if not g.os_path_exists(path):
g.es('clean directory does not exist',path)
return
try:
f = file(fileName,'w')
f.write(at.stringOutput)
f.close()
g.es_print('wrote',fileName)
except IOError:
g.es_print('can not write',fileName,color='red')
g.es_exception()
This will appear in test.leo and scripts.leo shortly. The node is
called
"Write cleaned files to 'clean' directory" in scripts.leo.
It doesn't actually have to be an @button node because all nodes are
scanned, regardless of the selected position when the script is
invoked.
Edward
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---