Commit 46218f5a authored by Andreas Freise's avatar Andreas Freise
Browse files

make block writing a bit more readable.

parent 5a013138
......@@ -393,14 +393,14 @@ class kat(object):
if values[1] == "FTblock":
newTag = values[2]
if self.__currentTag != None and newTag != self.__currentTag:
if self.__currentTag != None and self.__currentTag != NO_BLOCK:
warnings.warn("found block {0} before block {1} ended".format(newTag, self.__currentTag))
if newTag in self.__blocks:
raise pkex.BasePyKatException("Block `{0}` has already been read".format(newTag))
self.__blocks[newTag] = Block(newTag) # create new list to store all references to components in block
self.__currentTag = newTag
self.__currentTag = newTag
if values[1] == "FTend":
self.__currentTag = NO_BLOCK
......@@ -524,7 +524,7 @@ class kat(object):
raise pkex.BasePyKatException("pdtype command `{0}` is incorrect.".format(line))
self.__currentTag = NO_BLOCK
def saveScript(self, filename=None):
"""
Saves the current kat object to a Finesse input file
......@@ -812,11 +812,12 @@ class kat(object):
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
if key != NO_BLOCK:
out.append("\n")
if key != NO_BLOCK and np.size(objs)>0:
out.append("%%% FTblock " + key + "\n")
for obj in objs:
......@@ -833,7 +834,7 @@ class kat(object):
else:
out.append(txt + "\n")
if key != NO_BLOCK:
if key != NO_BLOCK and np.size(objs)>0:
out.append("%%% FTend " + key + "\n")
# now loop through all the nodes and get any gauss commands
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment