From 8476ef1b4ba94f9a18888c283baed0e21c5e058b Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Fri, 18 Nov 2022 21:47:27 +0100 Subject: [PATCH] fixed wrong python interperter in shebang line --- AppDir/usr/src/nmreval/io/merge_agr.py | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 AppDir/usr/src/nmreval/io/merge_agr.py diff --git a/AppDir/usr/src/nmreval/io/merge_agr.py b/AppDir/usr/src/nmreval/io/merge_agr.py new file mode 100755 index 0000000..8a52a07 --- /dev/null +++ b/AppDir/usr/src/nmreval/io/merge_agr.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 + +import re +import argparse + + +def merger(infiles, outfile): + header = '' + graphs = '' + counter = 0 + for f in infiles: + headerflag = True + for line in f.readlines(): + if re.match('@with [Gg][0-9]', line): + headerflag = False + # one graph per file, adjust graph number + line = '@with g{}\n'.format(counter) + if headerflag: + if graphs == '': + # save fonts, colors etc. of first file + header += line + elif re.match('@[Gg][0-9]', line): + # save graph specifications of following files + line = re.sub('@[Gg][0-9]', '@g{}'.format(counter), line) + header += line + else: + pass + else: + # save sets + if re.match('@target [Gg][0-9]', line): + line = re.sub('@target [Gg][0-9]', + '@target G{}'.format(counter), line) + graphs += line + counter += 1 + outfile.write(header+graphs) + + +parser = argparse.ArgumentParser() + +parser.add_argument('input', nargs='+', type=argparse.FileType('r'), + help='One or more input files') +parser.add_argument('--output', '-o', nargs='?', type=argparse.FileType('w'), + default='merger_grace.agr', + help='Output file (default=merged_grace.agr)') + +args = parser.parse_args() + +merger(args.input, args.output)