From c7194e7748da59fb60931bf002916e0324b92eeb Mon Sep 17 00:00:00 2001 From: Andreas Freise <adf@star.bham.ac.uk> Date: Sat, 22 Feb 2014 01:07:49 +0000 Subject: [PATCH] change order of blocks when generating script. First come all the read FTblocks, followed by the NO_BLOCK bits. --- pykat/finesse.py | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/pykat/finesse.py b/pykat/finesse.py index ae1214e..bb74831 100644 --- a/pykat/finesse.py +++ b/pykat/finesse.py @@ -805,22 +805,12 @@ class kat(object): if fragment in obj: print " ** removing line '{0}'".format(obj) objs.remove(obj) - + + def generateKatScript(self) : """ Generates the kat file which can then be run """ - - out = [] - import datetime - strtoday = datetime.datetime.now() - out.append(strtoday.strftime("%% Generated by PyKat %d.%m.%Y %H:%M:%S\n") ) - - for key in self.__blocks: - objs = self.__blocks[key].contents - out.append("\n") - if key != NO_BLOCK and np.size(objs)>0: - out.append("%%% FTblock " + key + "\n") - + def writeBlock(): for obj in objs: if isinstance(obj, str): out.append(obj + '\n') @@ -835,9 +825,33 @@ class kat(object): else: out.append(txt + "\n") - if key != NO_BLOCK and np.size(objs)>0: - out.append("%%% FTend " + key + "\n") - + + out = [] + import datetime + strtoday = datetime.datetime.now() + out.append(strtoday.strftime("%% Generated by PyKat %d.%m.%Y %H:%M:%S\n") ) + + # write the FTblocks + for key in self.__blocks: + objs = self.__blocks[key].contents + + if key != NO_BLOCK: + if np.size(objs)>0: + out.append("\n") + out.append("%%% FTblock " + key + "\n") + writeBlock() + out.append("%%% FTend " + key + "\n") + + # write the NO_BLOCK blocks + for key in self.__blocks: + objs = self.__blocks[key].contents + + + if key == NO_BLOCK: + if np.size(objs)>0: + out.append("\n") + writeBlock() + # now loop through all the nodes and get any gauss commands for key in self.nodes.getNodes(): txt = self.nodes.getNodes()[key].getFinesseText() -- GitLab