From e69d39434a5cc56fb9285fd398284f1241fdf0a4 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 8 Feb 2017 21:33:40 +0100 Subject: [PATCH] Add support for "[file ]" .sby sections --- sbysrc/sby_core.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sbysrc/sby_core.py b/sbysrc/sby_core.py index 9a7da46..705d4e0 100644 --- a/sbysrc/sby_core.py +++ b/sbysrc/sby_core.py @@ -127,6 +127,7 @@ class SbyJob: self.engines = list() self.script = list() self.files = dict() + self.verbatim_files = dict() self.models = dict() self.workdir = workdir self.status = "UNKNOWN" @@ -154,6 +155,7 @@ class SbyJob: with open(filename, "r") as f: for line in f: + raw_line = line line = line.strip() # print(line) @@ -183,6 +185,14 @@ class SbyJob: assert len(entries) == 1 continue + if entries[0] == "file": + mode = "file" + assert len(entries) == 2 + current_verbatim_file = entries[1] + assert current_verbatim_file not in self.verbatim_files + self.verbatim_files[current_verbatim_file] = list() + continue + if entries[0] == "files": mode = "files" assert len(entries) == 1 @@ -215,6 +225,10 @@ class SbyJob: assert False continue + if mode == "file": + self.verbatim_files[current_verbatim_file].append(raw_line) + continue + assert False def taskloop(self): @@ -251,6 +265,14 @@ class SbyJob: def copy_src(self): os.makedirs(self.workdir + "/src") + for dstfile, lines in self.verbatim_files.items(): + dstfile = self.workdir + "/src/" + dstfile + self.log("Writing '%s'." % dstfile) + + with open(dstfile, "w") as f: + for line in lines: + f.write(line) + for dstfile, srcfile in self.files.items(): dstfile = self.workdir + "/src/" + dstfile -- 2.30.2