Author: bugman Date: Wed Feb 3 18:26:28 2010 New Revision: 10630 URL: http://svn.gna.org/viewcvs/relax?rev=10630&view=rev Log: The introductory text for the prompt/script based interface is now recreated. The _build_intro_text() method has been added to replicate the formatting of the deleted get_intro_text() method of the main relax class. This formatting is only to be used in these 2 UIs. Modified: 1.3/prompt/interpreter.py Modified: 1.3/prompt/interpreter.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/interpreter.py?rev=10630&r1=10629&r2=10630&view=diff ============================================================================== --- 1.3/prompt/interpreter.py (original) +++ 1.3/prompt/interpreter.py Wed Feb 3 18:26:28 2010 @@ -29,9 +29,11 @@ # Python module imports. from code import InteractiveConsole, softspace from os import F_OK, access +import platform if dep_check.readline_module: import readline import sys +from textwrap import wrap # Python modules accessible on the command prompt. from math import pi @@ -43,6 +45,7 @@ from base_class import Exec_info from command import Ls, Lh, Ll, system from help import _Helper, _Helper_python +from intro import Intro_text if dep_check.readline_module: from tab_completion import Tab_completion @@ -93,11 +96,9 @@ class Interpreter: - def __init__(self, intro_string=None, show_script=True, quit=True, raise_relax_error=False): + def __init__(self, show_script=True, quit=True, raise_relax_error=False): """The interpreter class. - @param intro_string: The string to print at the start of execution. - @type intro_string: str @param show_script: If true, the relax will print the script contents prior to executing the script. @type show_script: bool @@ -111,10 +112,12 @@ """ # Place the arguments in the class namespace. - self.__intro_string = intro_string self.__show_script = show_script self.__quit_flag = quit self.__raise_relax_error = raise_relax_error + + # Build the intro string. + self.__intro_string = self._build_intro_text() # Initialise the execution information container (info that can change during execution). self.exec_info = Exec_info @@ -129,6 +132,49 @@ # Set up the interpreter objects. self._locals = self._setup() + + + def _build_intro_text(self): + """Create the introductory string to print out. + + @return: The introductory string. + @rtype: str + """ + + # The width of the printout. + if platform.uname()[0] in ['Windows', 'Microsoft']: + width = 80 + else: + width = 100 + + # Initialise the string and the intro class + string = '' + text = Intro_text() + + # Some new lines. + intro_string = '\n\n\n' + + # Program name and version. + intro_string = intro_string + text.centre(text.title + ' ' + text.version, width) + '\n\n' + + # Program description. + intro_string = intro_string + text.centre(text.desc, width) + '\n\n' + + # Copyright printout. + for i in range(len(text.copyright)): + intro_string = intro_string + text.centre(text.copyright[i], width) + '\n' + intro_string = intro_string + '\n' + + # Program licence and help (wrapped). + for line in wrap(text.licence, width): + intro_string = intro_string + line + '\n' + + # ImportErrors, if any. + for i in range(len(text.errors)): + intro_string = intro_string + '\n' + text.errors[i] + '\n' + + # Return the formatted text. + return intro_string def _setup(self):