From: Tobias Platen Date: Thu, 23 Jan 2020 12:12:48 +0000 (+0100) Subject: do not create output files on error X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ba24fe01625250eb4da3d86b01f6c3291791d8eb;p=sv2nmigen.git do not create output files on error --- diff --git a/absyn.py b/absyn.py index 60a87ba..e81e429 100644 --- a/absyn.py +++ b/absyn.py @@ -46,12 +46,18 @@ class Assignment: class Absyn: def __init__(self, outputfn): - self.outputfile = open(outputfn, "w") - self.outputfile.write(preamble) + self.outputfn = outputfn + self.outputfile = None self.assign = [] self.ports = [] + def open(self): + if(self.outputfile is None): + self.outputfile = open(self.outputfn, "w") + self.outputfile.write(preamble) + def printpy(self, p): + self.open() self.outputfile.write(str(p)+"\n") def assign(self, p): @@ -159,6 +165,7 @@ class Absyn: return clsdecl def appendComments(self, data): + self.open() self.outputfile.write(data) #lines = data.split("\n") # for line in lines: