mailr15769 - in /1.3: ansi.py prompt/base_class.py relax.py relax_errors.py relax_warnings.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on April 17, 2012 - 18:49:
Author: bugman
Date: Tue Apr 17 18:49:22 2012
New Revision: 15769

URL: http://svn.gna.org/viewcvs/relax?rev=15769&view=rev
Log:
Shifted the terminal colouring ANSI escape sequences into their own 'ansi' 
module.

This will allow the colours to be easily changed.


Added:
    1.3/ansi.py
Modified:
    1.3/prompt/base_class.py
    1.3/relax.py
    1.3/relax_errors.py
    1.3/relax_warnings.py

Added: 1.3/ansi.py
URL: http://svn.gna.org/viewcvs/relax/1.3/ansi.py?rev=15769&view=auto
==============================================================================
--- 1.3/ansi.py (added)
+++ 1.3/ansi.py Tue Apr 17 18:49:22 2012
@@ -1,0 +1,39 @@
+###############################################################################
+#                                                                            
 #
+# Copyright (C) 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 ANSI escape sequences for colour terminal output."""
+
+
+# The relax prompt.
+relax_prompt = "\033[94m"
+
+# RelaxErrors.
+relax_error = "\033[31m"
+
+# RelaxWarnings.
+relax_warning = "\033[33m"
+
+# The terminating sequence.
+end = "\033[0m"
+
+

Modified: 1.3/prompt/base_class.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/prompt/base_class.py?rev=15769&r1=15768&r2=15769&view=diff
==============================================================================
--- 1.3/prompt/base_class.py (original)
+++ 1.3/prompt/base_class.py Tue Apr 17 18:49:22 2012
@@ -30,6 +30,7 @@
 from textwrap import wrap
 
 # relax module imports.
+import ansi
 import help
 from status import Status; status = Status()
 from string import split, strip
@@ -226,9 +227,9 @@
         self.ps3 = '\n%s' % self.ps1
 
         # Coloured text.
-        self.ps1_colour = "\033[94m%s\033[0m" % self.ps1
-        self.ps2_colour = "\033[94m%s\033[0m" % self.ps2
-        self.ps3_colour = "\n\033[94m%s\033[0m" % self.ps1
+        self.ps1_colour = "%s%s%s" % (ansi.relax_promt, self.ps1, ansi.end)
+        self.ps2_colour = "%s%s%s" % (ansi.relax_promt, self.ps2, ansi.end)
+        self.ps3_colour = "\n%s%s%s" % (ansi.relax_promt, self.ps1, ansi.end)
 
 
 

Modified: 1.3/relax.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/relax.py?rev=15769&r1=15768&r2=15769&view=diff
==============================================================================
--- 1.3/relax.py (original)
+++ 1.3/relax.py Tue Apr 17 18:49:22 2012
@@ -51,7 +51,6 @@
 
 # relax modules.
 from info import Info_box
-import generic_fns
 from multi import Application_callback, load_multiprocessor
 from prompt.gpl import gpl
 from prompt import interpreter
@@ -140,9 +139,6 @@
 
         # Get and store the PID of this process.
         self.pid = getpid()
-
-        # Setup the object containing the generic functions.
-        self.generic = generic_fns
 
 
     def run(self):

Modified: 1.3/relax_errors.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/relax_errors.py?rev=15769&r1=15768&r2=15769&view=diff
==============================================================================
--- 1.3/relax_errors.py (original)
+++ 1.3/relax_errors.py Tue Apr 17 18:49:22 2012
@@ -36,6 +36,9 @@
 import time
 from types import ClassType
 
+# relax module imports.
+import ansi
+
 
 # Text variables.
 BIN = 'a binary number (0 or 1)'
@@ -106,9 +109,9 @@
 
         # Modify the error message to include 'RelaxError' at the start 
(using coloured text if a TTY).
         if sys.stderr.isatty():
-            return ("\033[31mRelaxError: " + self.text + "\033[0m\n")
-        else:
-            return ("RelaxError: " + self.text + "\n")
+            return ("%sRelaxError: %s%s\n" % (ansi.relax_error, self.text, 
ansi.end))
+        else:
+            return ("RelaxError: %s\n" % self.text)
 
 
 class BaseArgError(BaseError):

Modified: 1.3/relax_warnings.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/relax_warnings.py?rev=15769&r1=15768&r2=15769&view=diff
==============================================================================
--- 1.3/relax_warnings.py (original)
+++ 1.3/relax_warnings.py Tue Apr 17 18:49:22 2012
@@ -29,6 +29,7 @@
 import warnings
 
 # relax module imports.
+import ansi
 from status import Status; status = Status()
 
 
@@ -59,7 +60,7 @@
 
     # Text colouring
     if sys.stderr.isatty():
-        message = "\033[33m%s\033[0m" % message
+        message = "%s%s%s" % (ansi.relax_warning, message, ansi.end)
 
     # Return the warning message.
     return message




Related Messages


Powered by MHonArc, Updated Tue Apr 17 19:00:02 2012