1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Module containing the 'results' user function class."""
25 __docformat__ = 'plaintext'
26
27
28 from base_class import User_fn_class, _build_doc
29 import arg_check
30 from generic_fns import results
31
32
34 """Class for manipulating results."""
35
37
38 if self._exec_info.intro:
39 text = self._exec_info.ps3 + "results.display()"
40 print(text)
41
42
43 results.display()
44
45
46 display._doc_title = "Display the results."
47 display._doc_title_short = "Results display."
48 display._doc_desc = """
49 This will print to screen (STDOUT) the results contained within the current data pipe.
50 """
51 _build_doc(display)
52
53
54 - def read(self, file='results', dir=None):
68
69
70 read._doc_title = "Read results from a file."
71 read._doc_title_short = "Results reading."
72 read._doc_args = [
73 ["file", "The name of the file to read results from."],
74 ["dir", "The directory where the file is located."]
75 ]
76 read._doc_desc = """
77 This function is able to handle uncompressed, bzip2 compressed files, or gzip compressed files automatically. The full file name including extension can be supplied, however, if the file cannot be found the file with '.bz2' appended followed by the file name with '.gz' appended will be searched for.
78 """
79 _build_doc(read)
80
81
82 - def write(self, file='results', dir='pipe_name', compress_type=1, force=False):
83
84 if self._exec_info.intro:
85 text = self._exec_info.ps3 + "results.write("
86 text = text + "file=" + repr(file)
87 text = text + ", dir=" + repr(dir)
88 text = text + ", compress_type=" + repr(compress_type)
89 text = text + ", force=" + repr(force) + ")"
90 print(text)
91
92
93 arg_check.is_str_or_inst(file, 'file name')
94 arg_check.is_str(dir, 'directory name', can_be_none=True)
95 arg_check.is_int(compress_type, 'compression type')
96 arg_check.is_bool(force, 'force flag')
97
98
99 results.write(file=file, directory=dir, force=force, compress_type=compress_type)
100
101
102 write._doc_title = "Write the results to a file."
103 write._doc_title_short = "Results writing."
104 write._doc_args = [
105 ["file", "The name of the file to output results to. The default is 'results'. Optionally this can be a file object, or any object with a write() method."],
106 ["dir", "The directory name."],
107 ["compress_type", "The type of compression to use when creating the file."],
108 ["force", "A flag which if True will cause the results file to be overwritten."]
109 ]
110 write._doc_desc = """
111 To place the results file in the current working directory in the prompt and scripting modes, set dir to None. If dir is set to the special name 'pipe_name', then the results file will be placed into a directory with the same name as the current data pipe.
112
113 The default behaviour of this function is to compress the file using bzip2 compression. If the extension '.bz2' is not included in the file name, it will be added. The compression can, however, be changed to either no compression or gzip compression. This is controlled by the compression type which can be set to
114
115 0: No compression (no file extension),
116 1: bzip2 compression ('.bz2' file extension),
117 2: gzip compression ('.gz' file extension).
118
119 The complementary read function will automatically handle the compressed files.
120 """
121 _build_doc(write)
122