Commit e5c36c9b authored by Daniel Brown's avatar Daniel Brown
Browse files

updates for blocks

parent 9002c286
......@@ -11,6 +11,9 @@ from components import *
from structs import *
class Command(object):
def __init__(self):
self.tag = None
def getFinesseText(self):
""" Base class for individual finesse optical components """
raise NotImplementedError("This function is not implemented")
......
......@@ -34,6 +34,7 @@ class Component(object) :
self._nodes = None
self._requested_node_names = []
self._kat = None
self.tag = None
# store a unique ID for this component
global next_component_id
......
......@@ -18,6 +18,7 @@ class Detector(object) :
self._kat = None
self.noplot = False
self.enabled = True
self.tag = None
if node.find('*'):
self._alternate_beam = True
......
......@@ -141,11 +141,19 @@ class kat(object):
if values[0] == "%%%":
if values[1] == "FTblock":
newTag = values[2]
if newTag != self.__currentTag and self.__currentTag:
if self.__currentTag != None and newTag != self.__currentTag:
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")
self.__blocks{newTag} = [] # create new list to store all references to components in block
self.__currentTag = newTag
if values[1] == "FTend":
self.__currentTag = ""
self.__currentTag = None
continue
#warnings.warn("current tag {0}".format(self.__currentTag))
......@@ -174,6 +182,7 @@ class kat(object):
else:
print "Parsing `{0}` into pykat object not implemented yet, added as extra line.".format(line)
self.__extra_lines.append(line + "\n")
self.__currentTag= ""
def run(self, printout=1, printerr=1, save_output=False, save_kat=False,kat_name=None) :
......@@ -308,6 +317,7 @@ class kat(object):
def add(self, obj) :
try:
obj.tag = self.__currentTag
if isinstance(obj, Component):
if obj.name in self.__components :
......
Markdown is supported
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