1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """The results user function definitions."""
24
25
26 import dep_check
27 if dep_check.wx_module:
28 from wx import FD_OPEN, FD_SAVE
29 else:
30 FD_OPEN = -1
31 FD_SAVE = -1
32
33
34 from pipe_control import results
35 from user_functions.data import Uf_info; uf_info = Uf_info()
36 from user_functions.objects import Desc_container
37 from user_functions.wildcards import WILDCARD_RELAX_RESULT
38
39
40
41 uf_class = uf_info.add_class('results')
42 uf_class.title = "Class for manipulating results."
43 uf_class.menu_text = "&results"
44 uf_class.gui_icon = "relax.relax"
45
46
47
48 uf = uf_info.add_uf('results.display')
49 uf.title = "Display the results."
50 uf.title_short = "Results display."
51 uf.display = True
52
53 uf.desc.append(Desc_container())
54 uf.desc[-1].add_paragraph("This will print to screen (STDOUT) the results contained within the current data pipe.")
55 uf.backend = results.display
56 uf.menu_text = "&display"
57 uf.gui_icon = "oxygen.actions.document-preview"
58 uf.wizard_size = (600, 300)
59 uf.wizard_apply_button = False
60
61
62
63 uf = uf_info.add_uf('results.read')
64 uf.title = "Read the contents of a relax results file into the relax data store."
65 uf.title_short = "Results reading."
66 uf.add_keyarg(
67 name = "file",
68 default = "results",
69 py_type = "str",
70 arg_type = "file sel",
71 desc_short = "file name",
72 desc = "The name of the file to read results from.",
73 wiz_filesel_wildcard = WILDCARD_RELAX_RESULT,
74 wiz_filesel_style = FD_OPEN,
75 wiz_filesel_preview = False
76 )
77 uf.add_keyarg(
78 name = "dir",
79 py_type = "str",
80 arg_type = "dir",
81 desc_short = "directory name",
82 desc = "The directory where the file is located.",
83 can_be_none = True
84 )
85
86 uf.desc.append(Desc_container())
87 uf.desc[-1].add_paragraph("This 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.")
88 uf.backend = results.read
89 uf.menu_text = "&read"
90 uf.gui_icon = "oxygen.actions.document-open"
91 uf.wizard_size = (700, 500)
92 uf.wizard_apply_button = False
93
94
95
96 uf = uf_info.add_uf('results.write')
97 uf.title = "Write the results to a file."
98 uf.title_short = "Results writing."
99 uf.add_keyarg(
100 name = "file",
101 default = "results",
102 py_type = "str_or_inst",
103 arg_type = "file sel",
104 desc_short = "file name",
105 desc = "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 wiz_filesel_wildcard = WILDCARD_RELAX_RESULT,
107 wiz_filesel_style = FD_SAVE
108 )
109 uf.add_keyarg(
110 name = "dir",
111 default = "pipe_name",
112 py_type = "str",
113 arg_type = "dir",
114 desc_short = "directory name",
115 desc = "The directory name.",
116 can_be_none = True
117 )
118 uf.add_keyarg(
119 name = "compress_type",
120 default = 1,
121 py_type = "int",
122 desc_short = "compression type",
123 desc = "The type of compression to use when creating the file.",
124 wiz_element_type = "combo",
125 wiz_combo_choices = [
126 "No compression",
127 "bzip2 compression",
128 "gzip compression"
129 ],
130 wiz_combo_data = [
131 0,
132 1,
133 2
134 ],
135 wiz_read_only = True,
136 )
137 uf.add_keyarg(
138 name = "force",
139 default = False,
140 py_type = "bool",
141 desc_short = "force flag",
142 desc = "A flag which if True will cause the results file to be overwritten."
143 )
144
145 uf.desc.append(Desc_container())
146 uf.desc[-1].add_paragraph("This will write the entire contents of the current data pipe into an XML formatted file. This results file can then be read back into relax at a later point in time, or transfered to another machine. This is in contrast to the state.save user function whereby the entire data store, including all data pipes, are saved into a similarly XML formatted file.")
147 uf.desc[-1].add_paragraph("To place the results file in the current working directory in the prompt and scripting modes, leave the directory unset. If the directory 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.")
148 uf.desc[-1].add_paragraph("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")
149 uf.desc[-1].add_item_list_element("0", "No compression (no file extension),")
150 uf.desc[-1].add_item_list_element("1", "bzip2 compression ('.bz2' file extension),")
151 uf.desc[-1].add_item_list_element("2", "gzip compression ('.gz' file extension).")
152 uf.desc[-1].add_paragraph("The complementary read function will automatically handle the compressed files.")
153 uf.backend = results.write
154 uf.menu_text = "&write"
155 uf.gui_icon = "oxygen.actions.document-save"
156 uf.wizard_height_desc = 450
157 uf.wizard_size = (1000, 750)
158 uf.wizard_apply_button = False
159