Author: bugman Date: Wed Feb 3 18:00:17 2010 New Revision: 10627 URL: http://svn.gna.org/viewcvs/relax?rev=10627&view=rev Log: Redesigned get_intro_string() to return a container of different strings. The method is now called get_intro_text() and returns a container with the following str objects: - title: The program title 'relax' - version: For example 'repository checkout' or '1.3.8'. - desc: The short program description. - copyright: A list of copyright statements. - licence: Text pertaining to the licencing. - errors: A list of import errors. This is being abstracted so that the different UIs can use this differently. The prompt/script can word wrap to 100 char (80 char in Windows), and print this to stdout. The GUI can use this in the about prompt and not print to stdout. Other interfaces can use this in any other way. And the information content can be expanded for different purposes. Modified: 1.3/relax Modified: 1.3/relax URL: http://svn.gna.org/viewcvs/relax/1.3/relax?rev=10627&r1=10626&r2=10627&view=diff ============================================================================== --- 1.3/relax (original) +++ 1.3/relax Wed Feb 3 18:00:17 2010 @@ -56,13 +56,17 @@ from relax_io import io_streams_log, io_streams_tee import relax_warnings from test_suite.test_suite_runner import Test_suite_runner -import version +from version import version sys.path.append(sys.path[0]) sys.path[0] = '.' putenv('PDBVIEWER', 'vmd') +class Container: + """An empty container.""" + + class Relax: """The main relax class. @@ -73,9 +77,6 @@ def __init__(self): """The top level class for initialising the program.""" - # relax version number. - self.version = version.version - # Get and store the PID of this process. self.pid = getpid() @@ -87,9 +88,6 @@ # Pedantic flag (default is off). self.Pedantic = 0 - - # Set the program introduction string to nothing. - self.intro_string = None # Setup the object containing the generic functions. self.generic = generic_fns @@ -107,7 +105,7 @@ # Show the version number and exit. if mode == 'version': - print(('relax ' + self.version)) + print(('relax ' + version)) sys.exit() # Logging. @@ -119,12 +117,12 @@ io_streams_tee(tee_file) # Create a string to pass to the interpreter to print. - intro_string = self.get_intro_string() + intro_text = self.get_intro_text() # Run the interpreter for the prompt or script modes. if mode == 'prompt' or mode == 'script': # Run the interpreter. - self.interpreter = interpreter.Interpreter(intro_string) + self.interpreter = interpreter.Interpreter(intro_text) self.interpreter.run(self.script_file) # Execute the relax test suite @@ -305,57 +303,47 @@ return mode, log_file, tee_file - def get_intro_string(self): + def get_intro_text(self): """Create the program introduction. - @return: The program introduction string. + This method returns a container with the following objects: + - title: The program title 'relax' + - version: For example 'repository checkout' or '1.3.8'. + - desc: The short program description. + - copyright: A list of copyright statements. + - licence: Text pertaining to the licencing. + - errors: A list of import errors. + + + @return: The program introduction string container. @rtype: str """ - # The width of the printout. - if self.platform == 'Windows' or self.platform == 'Microsoft': - width = 80 - else: - width = 100 - - # Some new lines. - intro_string = '\n\n\n' + # The container. + text = Container() # Program name and version. - string = "relax " + self.version - intro_string = intro_string + self.spacing(string, width) + '\n\n' + text.title = "relax" + text.version = version # Program description. - string = "Protein dynamics by NMR relaxation data analysis" - intro_string = intro_string + self.spacing(string, width) + '\n\n' + text.desc = "Protein dynamics by NMR data analysis" # Copyright printout. - string = "Copyright (C) 2001-2006 Edward d'Auvergne" - intro_string = intro_string + self.spacing(string, width) + '\n' - string = "Copyright (C) 2006-2010 the relax development team" - intro_string = intro_string + self.spacing(string, width) + '\n\n' - - # Program licence and help (80 characters wide). - if width == 80: - intro_string = intro_string + "This is free software which you are welcome to modify and redistribute under\n" - intro_string = intro_string + "the conditions of the GNU General Public License (GPL). This program,\n" - intro_string = intro_string + "including all modules, is licensed under the GPL and comes with absolutely no\n" - intro_string = intro_string + "warranty. For details type 'GPL'. Assistance in using this program can be\n" - intro_string = intro_string + "accessed by typing 'help'.\n" - - # Program licence and help (100 characters wide). - else: - intro_string = intro_string + "This is free software which you are welcome to modify and redistribute under the conditions of the\n" - intro_string = intro_string + "GNU General Public License (GPL). This program, including all modules, is licensed under the GPL\n" - intro_string = intro_string + "and comes with absolutely no warranty. For details type 'GPL'. Assistance in using this program\n" - intro_string = intro_string + "can be accessed by typing 'help'.\n" + text.copyright = [] + text.copyright.append("Copyright (C) 2001-2006 Edward d'Auvergne") + text.copyright.append("Copyright (C) 2006-2010 the relax development team") + + # Program licence and help. + text.licence = "This is free software which you are welcome to modify and redistribute under the conditions of the GNU General Public License (GPL). This program, including all modules, is licensed under the GPL and comes with absolutely no warranty. For details type 'GPL'. Assistance in using this program can be accessed by typing 'help'." # ImportErrors, if any. + text.errors = [] if not dep_check.C_module_exp_fn: - intro_string = intro_string + "\n" + dep_check.C_module_exp_fn_mesg + "\n" - - # Return the string. - return intro_string + text.errors.append(dep_check.C_module_exp_fn_mesg) + + # Return the container. + return text def licence(self):