From 803d5ea4b4d35b4dbcdde7d82d7a7c2a3ce8b3be Mon Sep 17 00:00:00 2001 From: "Christoph.Knote" <christoph.knote@physik.uni-muenchen.de> Date: Thu, 14 Dec 2017 16:07:38 +0100 Subject: [PATCH] Write method for output files added. --- boxmox/data.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/boxmox/data.py b/boxmox/data.py index 9982ede..6872bc1 100644 --- a/boxmox/data.py +++ b/boxmox/data.py @@ -268,6 +268,15 @@ class Output(object): os.remove(self.fpath) except Exception as e: raise("Removing output file did not work: {:s}".format(str(e))) + def write(self, f=sys.stdout): + ''' + Write contents of Output into file + + :param File f: file object or stream where to write to, defaults to sysout. + ''' + with open(self.fpath, 'rb') as i: + for line in i: + f.write(i) def copy(self, target_path): ''' Copy output file to target_path -- GitLab