Author: bugman Date: Thu May 10 20:51:51 2012 New Revision: 16210 URL: http://svn.gna.org/viewcvs/relax?rev=16210&view=rev Log: Converted the results user functions to the auto-generation design. Added: branches/uf_redesign/user_functions/results.py - copied, changed from r16206, branches/uf_redesign/prompt/results.py Removed: branches/uf_redesign/prompt/results.py Modified: branches/uf_redesign/prompt/__init__.py branches/uf_redesign/prompt/interpreter.py branches/uf_redesign/user_functions/__init__.py Modified: branches/uf_redesign/prompt/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/__init__.py?rev=16210&r1=16209&r2=16210&view=diff ============================================================================== --- branches/uf_redesign/prompt/__init__.py (original) +++ branches/uf_redesign/prompt/__init__.py Thu May 10 20:51:51 2012 @@ -28,7 +28,6 @@ 'help', 'interpreter', 'objects', - 'results', 'sequence', 'spectrum', 'spin', Modified: branches/uf_redesign/prompt/interpreter.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/interpreter.py?rev=16210&r1=16209&r2=16210&view=diff ============================================================================== --- branches/uf_redesign/prompt/interpreter.py (original) +++ branches/uf_redesign/prompt/interpreter.py Thu May 10 20:51:51 2012 @@ -61,7 +61,6 @@ # User classes. from structure import Structure -from results import Results from sequence import Sequence from spectrum import Spectrum from spin import Spin @@ -182,7 +181,6 @@ objects['temperature'] = temp.set # Place the user classes in the local namespace. - objects['results'] = Results() objects['sequence'] = Sequence() objects['spectrum'] = Spectrum() objects['spin'] = Spin() Removed: branches/uf_redesign/prompt/results.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/results.py?rev=16209&view=auto ============================================================================== --- branches/uf_redesign/prompt/results.py (original) +++ branches/uf_redesign/prompt/results.py (removed) @@ -1,122 +1,0 @@ -############################################################################### -# # -# Copyright (C) 2003-2012 Edward d'Auvergne # -# # -# This file is part of the program relax. # -# # -# relax is free software; you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation; either version 2 of the License, or # -# (at your option) any later version. # -# # -# relax is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with relax; if not, write to the Free Software # -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# # -############################################################################### - -# Module docstring. -"""Module containing the 'results' user function class.""" -__docformat__ = 'plaintext' - -# relax module imports. -from base_class import User_fn_class, _build_doc -import arg_check -from generic_fns import results -from status import Status; status = Status() - - -class Results(User_fn_class): - """Class for manipulating results.""" - - def display(self): - # Function intro text. - if status.prompt_intro: - text = status.ps3 + "results.display()" - print(text) - - # Execute the functional code. - results.display() - - # The function doc info. - display._doc_title = "Display the results." - display._doc_title_short = "Results display." - display._doc_desc = """ - This will print to screen (STDOUT) the results contained within the current data pipe. - """ - _build_doc(display) - - - def read(self, file='results', dir=None): - # Function intro text. - if status.prompt_intro: - text = status.ps3 + "results.read(" - text = text + "file=" + repr(file) - text = text + ", dir=" + repr(dir) + ")" - print(text) - - # The argument checks. - arg_check.is_str(file, 'file name') - arg_check.is_str(dir, 'directory name', can_be_none=True) - - # Execute the functional code. - results.read(file=file, directory=dir) - - # The function doc info. - read._doc_title = "Read results from a file." - read._doc_title_short = "Results reading." - read._doc_args = [ - ["file", "The name of the file to read results from."], - ["dir", "The directory where the file is located."] - ] - read._doc_desc = """ - 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. - """ - _build_doc(read) - - - def write(self, file='results', dir='pipe_name', compress_type=1, force=False): - # Function intro text. - if status.prompt_intro: - text = status.ps3 + "results.write(" - text = text + "file=" + repr(file) - text = text + ", dir=" + repr(dir) - text = text + ", compress_type=" + repr(compress_type) - text = text + ", force=" + repr(force) + ")" - print(text) - - # The argument checks. - arg_check.is_str_or_inst(file, 'file name') - arg_check.is_str(dir, 'directory name', can_be_none=True) - arg_check.is_int(compress_type, 'compression type') - arg_check.is_bool(force, 'force flag') - - # Execute the functional code. - results.write(file=file, directory=dir, force=force, compress_type=compress_type) - - # The function doc info. - write._doc_title = "Write the results to a file." - write._doc_title_short = "Results writing." - write._doc_args = [ - ["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."], - ["dir", "The directory name."], - ["compress_type", "The type of compression to use when creating the file."], - ["force", "A flag which if True will cause the results file to be overwritten."] - ] - write._doc_desc = """ - 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. - - 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 - - 0: No compression (no file extension), - 1: bzip2 compression ('.bz2' file extension), - 2: gzip compression ('.gz' file extension). - - The complementary read function will automatically handle the compressed files. - """ - _build_doc(write) Modified: branches/uf_redesign/user_functions/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/__init__.py?rev=16210&r1=16209&r2=16210&view=diff ============================================================================== --- branches/uf_redesign/user_functions/__init__.py (original) +++ branches/uf_redesign/user_functions/__init__.py Thu May 10 20:51:51 2012 @@ -67,6 +67,7 @@ 'relax_fit', 'residue', 'reset', + 'results', 'select', 'state' ] @@ -105,6 +106,7 @@ import user_functions.relax_fit import user_functions.residue import user_functions.reset +import user_functions.results import user_functions.select import user_functions.state Copied: branches/uf_redesign/user_functions/results.py (from r16206, branches/uf_redesign/prompt/results.py) URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/results.py?p2=branches/uf_redesign/user_functions/results.py&p1=branches/uf_redesign/prompt/results.py&r1=16206&r2=16210&rev=16210&view=diff ============================================================================== --- branches/uf_redesign/prompt/results.py (original) +++ branches/uf_redesign/user_functions/results.py Thu May 10 20:51:51 2012 @@ -21,102 +21,129 @@ ############################################################################### # Module docstring. -"""Module containing the 'results' user function class.""" -__docformat__ = 'plaintext' +"""Module containing the 'results' user function data.""" # relax module imports. -from base_class import User_fn_class, _build_doc -import arg_check from generic_fns import results -from status import Status; status = Status() +from graphics import WIZARD_IMAGE_PATH +from user_functions.data import Uf_info; uf_info = Uf_info() -class Results(User_fn_class): - """Class for manipulating results.""" - - def display(self): - # Function intro text. - if status.prompt_intro: - text = status.ps3 + "results.display()" - print(text) - - # Execute the functional code. - results.display() - - # The function doc info. - display._doc_title = "Display the results." - display._doc_title_short = "Results display." - display._doc_desc = """ - This will print to screen (STDOUT) the results contained within the current data pipe. - """ - _build_doc(display) +# The user function class. +uf_class = uf_info.add_class('results') +uf_class.title = "Class for manipulating results." +uf_class.menu_text = "&results" +uf_class.gui_icon = "relax.relax" - def read(self, file='results', dir=None): - # Function intro text. - if status.prompt_intro: - text = status.ps3 + "results.read(" - text = text + "file=" + repr(file) - text = text + ", dir=" + repr(dir) + ")" - print(text) - - # The argument checks. - arg_check.is_str(file, 'file name') - arg_check.is_str(dir, 'directory name', can_be_none=True) - - # Execute the functional code. - results.read(file=file, directory=dir) - - # The function doc info. - read._doc_title = "Read results from a file." - read._doc_title_short = "Results reading." - read._doc_args = [ - ["file", "The name of the file to read results from."], - ["dir", "The directory where the file is located."] - ] - read._doc_desc = """ - 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. - """ - _build_doc(read) +# The results.display user function. +uf = uf_info.add_uf('results.display') +uf.title = "Display the results." +uf.title_short = "Results display." +uf.display = True +uf.desc = """ +This will print to screen (STDOUT) the results contained within the current data pipe. +""" +uf.backend = results.display +uf.menu_text = "&display" +uf.gui_icon = "oxygen.actions.document-preview" +uf.wizard_size = (600, 300) +uf.wizard_apply_button = False - def write(self, file='results', dir='pipe_name', compress_type=1, force=False): - # Function intro text. - if status.prompt_intro: - text = status.ps3 + "results.write(" - text = text + "file=" + repr(file) - text = text + ", dir=" + repr(dir) - text = text + ", compress_type=" + repr(compress_type) - text = text + ", force=" + repr(force) + ")" - print(text) +# The results.read user function. +uf = uf_info.add_uf('results.read') +uf.title = "Read the contents of a relax results file into the relax data store." +uf.title_short = "Results reading." +uf.add_keyarg( + name = "file", + default = "results", + py_type = "str", + arg_type = "file sel", + desc_short = "file name", + desc = "The name of the file to read results from." +) +uf.add_keyarg( + name = "directory", + py_type = "str", + arg_type = "dir", + desc_short = "directory name", + desc = "The directory where the file is located.", + can_be_none = True +) +uf.desc = """ +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. +""" +uf.backend = results.read +uf.menu_text = "&read" +uf.gui_icon = "oxygen.actions.document-open" +uf.wizard_size = (700, 500) +uf.wizard_apply_button = False - # The argument checks. - arg_check.is_str_or_inst(file, 'file name') - arg_check.is_str(dir, 'directory name', can_be_none=True) - arg_check.is_int(compress_type, 'compression type') - arg_check.is_bool(force, 'force flag') - # Execute the functional code. - results.write(file=file, directory=dir, force=force, compress_type=compress_type) +# The results.write user function. +uf = uf_info.add_uf('results.write') +uf.title = "Write the results to a file." +uf.title_short = "Results writing." +uf.add_keyarg( + name = "file", + default = "results", + py_type = "str_or_inst", + arg_type = "file sel", + desc_short = "file name", + 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." +) +uf.add_keyarg( + name = "directory", + default = "pipe_name", + py_type = "str", + arg_type = "dir", + desc_short = "directory name", + desc = "The directory name.", + can_be_none = True +) +uf.add_keyarg( + name = "compress_type", + default = 1, + py_type = "int", + desc_short = "compression type", + desc = "The type of compression to use when creating the file.", + wiz_element_type = "combo", + wiz_combo_choices = [ + "No compression", + "bzip2 compression", + "gzip compression" + ], + wiz_combo_data = [ + 0, + 1, + 2 + ], + wiz_read_only = True, +) +uf.add_keyarg( + name = "force", + default = False, + py_type = "bool", + desc_short = "force flag", + desc = "A flag which if True will cause the results file to be overwritten." +) +uf.desc = """ +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. - # The function doc info. - write._doc_title = "Write the results to a file." - write._doc_title_short = "Results writing." - write._doc_args = [ - ["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."], - ["dir", "The directory name."], - ["compress_type", "The type of compression to use when creating the file."], - ["force", "A flag which if True will cause the results file to be overwritten."] - ] - write._doc_desc = """ - 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. +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. - 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 +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 - 0: No compression (no file extension), - 1: bzip2 compression ('.bz2' file extension), - 2: gzip compression ('.gz' file extension). + 0: No compression (no file extension), + 1: bzip2 compression ('.bz2' file extension), + 2: gzip compression ('.gz' file extension). - The complementary read function will automatically handle the compressed files. - """ - _build_doc(write) +The complementary read function will automatically handle the compressed files. +""" +uf.backend = results.write +uf.menu_text = "&write" +uf.gui_icon = "oxygen.actions.document-save" +uf.wizard_height_desc = 400 +uf.wizard_size = (1000, 800) +uf.wizard_apply_button = False