1
2 """Basic file output"""
3
5 """File for data output
6
7 The format of the file is: one data-set per line
8 Values are separated by tabs
9
10 The file is created the first time it is written"""
11
13 """name - name of the file"""
14 self.name=name
15 self.isOpen=False
16 self.handle=None
17
19 """A hook for outputting stuff at the beginning of the file"""
20 pass
21
23 """A hook for outputting stuff at the end of the file"""
24 pass
25
27 """A hook for outputting stuff at the end of each line"""
28 pass
29
31 """A hook for outputting stuff at the start of each line"""
32 pass
33
35 """get the file-handle. File is created and opened if it
36 wasn't opened before"""
37 if not self.isOpen:
38 self.handle=open(self.name,"w")
39 self.isOpen=True
40 self.outputAtStart()
41
42 return self.handle
43
60
62 """close the file"""
63
64 if self.handle!=None:
65 self.outputAtEnd()
66 self.handle.close()
67 self.handle=None
68