Author: bugman Date: Mon Jan 7 18:28:57 2008 New Revision: 4453 URL: http://svn.gna.org/viewcvs/relax?rev=4453&view=rev Log: Completely changed how the relax program introduction is handled. Modified: 1.3/prompt/interpreter.py 1.3/relax Modified: 1.3/prompt/interpreter.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/interpreter.py?rev=4453&r1=4452&r2=4453&view=diff ============================================================================== --- 1.3/prompt/interpreter.py (original) +++ 1.3/prompt/interpreter.py Mon Jan 7 18:28:57 2008 @@ -78,11 +78,20 @@ class Interpreter: - def __init__(self, relax): - """The interpreter class.""" + def __init__(self, relax, intro_string=None): + """The interpreter class. + + @param relax: The relax instance. + @type relax: instance + @param intro_string: The string to print at the start of execution. + @type intro_string: str + """ # Place the program class structure under self.relax self.relax = relax + + # Program intro string. + self.intro_string = intro_string # The prompts. sys.ps1 = 'relax> ' @@ -143,8 +152,9 @@ The namespace of this function is the namespace seen inside the interpreter. All user accessible functions, classes, etc, should be placed in this namespace. - @param script_file: The script file to be executed. For the interpreter mode, this should - be left as None. + + @param script_file: The script file to be executed. For the interpreter mode, this + should be left as None. @type script_file: None or str @param quit: If true, the default, then relax will exit after running this function. @type quit: bool @@ -227,7 +237,7 @@ self.intro = 1 # Run the script. - run_script(intro=self.relax.intro_string, local=self.local, script_file=script_file, quit=quit) + run_script(intro=self.intro_string, local=self.local, script_file=script_file, quit=quit) # Test for the dummy mode for generating documentation (then exit). elif hasattr(self.relax, 'dummy_mode'): @@ -237,7 +247,7 @@ # Go to the prompt. else: - prompt(intro=self.relax.intro_string, local=self.local) + prompt(intro=self.intro_string, local=self.local) def _off(self): Modified: 1.3/relax URL: http://svn.gna.org/viewcvs/relax/1.3/relax?rev=4453&r1=4452&r2=4453&view=diff ============================================================================== --- 1.3/relax (original) +++ 1.3/relax Mon Jan 7 18:28:57 2008 @@ -139,13 +139,13 @@ elif tee_file and mode != 'thread': tee(tee_file) + # Create a string to pass to the interpreter to print. + intro_string = self.get_intro_string() + # Run the interpreter for the prompt or script modes. if mode == 'prompt' or mode == 'script': - # Create a string to pass to the interpreter to print. - self.set_intro_string() - # Run the interpreter. - self.interpreter = interpreter.Interpreter(self) + self.interpreter = interpreter.Interpreter(self, intro_string) self.interpreter.run(self.script_file) # Threading mode. @@ -167,9 +167,6 @@ # Execute the relax test suite elif mode == 'test suite': - # Create a string to pass to the interpreter to print. - self.set_intro_string() - # Load the interpreter and turn intros on. self.interpreter = interpreter.Interpreter(self) self.interpreter._on() @@ -180,9 +177,6 @@ # Execute the relax system tests. elif mode == 'system tests': - # Create a string to pass to the interpreter to print. - self.set_intro_string() - # Load the interpreter and turn intros on. self.interpreter = interpreter.Interpreter(self) self.interpreter._on() @@ -193,9 +187,6 @@ # Execute the relax unit tests. elif mode == 'unit tests': - # Create a string to pass to the interpreter to print. - self.set_intro_string() - # Run the tests. runner = Test_suite_runner(self) runner.run_unit_tests() @@ -366,14 +357,12 @@ return mode, log_file, tee_file - def licence(self): - """Function for displaying the licence.""" - - help(gpl) - - - def set_intro_string(self): - """Create the program introduction.""" + def get_intro_string(self): + """Create the program introduction. + + @return: The program introduction string. + @type return: str + """ # The width of the printout. if self.platform == 'Windows' or self.platform == 'Microsoft': @@ -382,36 +371,45 @@ width = 100 # Some new lines. - self.intro_string = '\n\n\n' + intro_string = '\n\n\n' # Program name and version. string = "relax " + self.version - self.intro_string = self.intro_string + self.spacing(string, width) + '\n\n' + intro_string = intro_string + self.spacing(string, width) + '\n\n' # Program description. string = "Protein dynamics by NMR relaxation data analysis" - self.intro_string = self.intro_string + self.spacing(string, width) + '\n\n' + intro_string = intro_string + self.spacing(string, width) + '\n\n' # Copyright printout. string = "Copyright (C) 2001-2006 Edward d'Auvergne" - self.intro_string = self.intro_string + self.spacing(string, width) + '\n' + intro_string = intro_string + self.spacing(string, width) + '\n' string = "Copyright (C) 2006-2008 the relax development team" - self.intro_string = self.intro_string + self.spacing(string, width) + '\n\n' + intro_string = intro_string + self.spacing(string, width) + '\n\n' # Program licence and help (80 characters wide). if width == 80: - self.intro_string = self.intro_string + "This is free software which you are welcome to modify and redistribute under\n" - self.intro_string = self.intro_string + "the conditions of the GNU General Public License (GPL). This program,\n" - self.intro_string = self.intro_string + "including all modules, is licensed under the GPL and comes with absolutely no\n" - self.intro_string = self.intro_string + "warranty. For details type 'GPL'. Assistance in using this program can be\n" - self.intro_string = self.intro_string + "accessed by typing 'help'.\n" + 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: - self.intro_string = self.intro_string + "This is free software which you are welcome to modify and redistribute under the conditions of the\n" - self.intro_string = self.intro_string + "GNU General Public License (GPL). This program, including all modules, is licensed under the GPL\n" - self.intro_string = self.intro_string + "and comes with absolutely no warranty. For details type 'GPL'. Assistance in using this program\n" - self.intro_string = self.intro_string + "can be accessed by typing 'help'.\n" + 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" + + # Return the string. + return intro_string + + + def licence(self): + """Function for displaying the licence.""" + + help(gpl) def spacing(self, string, width=100):