From de1b92f2d981fa47984f3709b16a53c73efd03fc Mon Sep 17 00:00:00 2001
From: Marko Mecina <marko.mecina@univie.ac.at>
Date: Wed, 14 Feb 2024 17:14:32 +0100
Subject: [PATCH] properly comment out multi-line pre/post-condition
 description in generated scripts

---
 Tst/json_to_barescript.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Tst/json_to_barescript.py b/Tst/json_to_barescript.py
index 7093702..de0eafd 100755
--- a/Tst/json_to_barescript.py
+++ b/Tst/json_to_barescript.py
@@ -45,7 +45,7 @@ def run(jfile, outfile, reportfunc=False, specfile=None):
         script += 'ask_tc_exec = True\n'
         script += 'report = cfl.TestReport(specfile, rep_version, mib_version, gui=True)\n\n'
 
-    script += '# Precond.\n# {}\n#! CCS.BREAKPOINT\n\n'.format(data['_precon_descr'])
+    script += '# Precond.\n# {}\n#! CCS.BREAKPOINT\n\n'.format(replace_newline(data['_precon_descr']))
     # script += '{}\n\n\n'.format(data['_precon_code'].strip())  # Add the precondition code
 
     for step in data['sequences'][0]['steps']:
@@ -74,7 +74,7 @@ def run(jfile, outfile, reportfunc=False, specfile=None):
 
         script += txt
 
-    script += '# Postcond.\n# {}\n'.format(data['_postcon_descr'])
+    script += '# Postcond.\n# {}\n'.format(replace_newline(data['_postcon_descr']))
     # script += data['_postcon_code'].strip()  # Add the postcondition code
 
     if reportfunc:
@@ -87,6 +87,10 @@ def run(jfile, outfile, reportfunc=False, specfile=None):
         fd.write(script)
 
 
+def replace_newline(txt):
+    return txt.strip().replace('\n', '\n# ')
+
+
 if __name__ == '__main__':
     json_file_path = sys.argv[1]
 
-- 
GitLab