Skip to content
Snippets Groups Projects
Commit b2671161 authored by mads's avatar mads
Browse files

fix multiple exit bug in htc file

parent 0feaf152
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -163,6 +163,8 @@ class HTCLine(HTCContents):
return str(self)
def __str__(self, level=0):
if self.name_ == "":
return ""
return "%s%s%s;%s\n" % (" "*(level), self.name_,
("", "\t" + self.str_values())[bool(self.values)],
("", "\t" + self.comments)[bool(self.comments.strip())])
......@@ -191,6 +193,11 @@ class HTCLine(HTCContents):
values = [fmt(v) for v in values]
return HTCLine(name, values, end_comments)
def remove(self):
self.name_ = ""
self.values = []
self.comments = ""
class HTCOutputSection(HTCSection):
sensors = None
......
......@@ -66,7 +66,11 @@ class HTCFile(HTCContents, HTCDefaults):
if l.lower().lstrip().startswith('continue_in_file'):
filename = l.lstrip().split(";")[0][len("continue_in_file"):].strip()
filename = os.path.join(os.path.dirname(self.filename), self.modelpath, filename)
htc_lines.extend(self.readlines(filename))
for line in self.readlines(filename):
if line.lstrip().lower().startswith('exit'):
break
htc_lines.append(line)
else:
htc_lines.append(l)
return htc_lines
......
......@@ -205,6 +205,8 @@ class TestHtcFile(unittest.TestCase):
self.assertIn('main_body__31', htcfile.new_htc_structure.keys())
self.assertIn(os.path.abspath(self.testfilepath + 'orientation.dat'), [os.path.abspath(f) for f in htcfile.input_files()])
self.assertIn('./data/NREL_5MW_st1.txt', htcfile.input_files())
self.assertEqual(str(htcfile).count("exit"), 1)
self.assertIn('filename\t./res/oc4_p2_Load_case_eq;', str(htcfile))
def test_tjul_example(self):
htcfile = HTCFile(self.testfilepath + "./tjul.htc", ".")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment