On 08/06/2014 10:55 AM, Zoltan Benedek wrote:
In order to avoid useless changes of the leo file in SCMS you can run
the 'contract-all' command before every commit.
Good idea.
Attached is a script that allows you to do the contractions from the
command line.
usage: contract_all_nodes.py [options] path1 [path2 ...]
Contract all nodes
positional arguments:
path Pathname of a Leo-Editor file. If doesn't end .leo,
then .leo is added automatically.
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
--
Segundo Bob
[email protected]
--
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.
#!/usr/bin/python
#coding=utf-8
#@+leo-ver=5-thin
#@+node:bob07.20140806134356.1600: * @file contract_all_nodes.py
#@@first
#@@first
#@@language python
#@@tabwidth -4
#@+<< imports >>
#@+node:bob07.20140806134356.1601: ** << imports >>
import argparse
import leo.core.leoBridge as leoBridge
#@-<< imports >>
#@+<< version >>
#@+node:bob07.20140806134356.1602: ** << version >>
version = '1.0'
#@-<< version >>
#@+others
#@+node:bob07.20140806134356.1603: ** cmdLineHandler()
def cmdLineHandler():
"""
Command Line Handler
@param return: argparse.Namespace object containing all the parsed
command line arguments.
"""
parser = argparse.ArgumentParser(description='Contract all nodes',
usage='%(prog)s [options] path1 [path2 ...]')
parser.add_argument('-v', '--version', action='version',
version='%(prog)s Revision {0}'.format(version))
parser.add_argument('path', nargs='*', help='Pathname of a Leo-Editor '
"file. If doesn't end .leo, then .leo is added automatically.")
args = parser.parse_args()
return args
#@+node:bob07.20140806134356.1604: ** main()
def main():
""" Module entry point
"""
args = cmdLineHandler()
fnList = list()
for fpn in args.path:
if not fpn.endswith('.leo'):
fpn = fpn + '.leo'
fnList.append(fpn)
bridge = leoBridge.controller(gui='nullGui', verbose=False,
loadPlugins=False, readSettings=False)
for fpn in fnList:
cmdrX = bridge.openLeoFile(fpn)
cmdrX.contractAllHeadlines()
cmdrX.save()
cmdrX.close()
#@-others
if __name__ == "__main__":
main()
#@-leo