mailr16294 - in /branches/uf_redesign: gui/uf_objects.py prompt/base_class.py prompt/uf_objects.py relax_string.py


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

Header


Content

Posted by edward on May 13, 2012 - 18:01:
Author: bugman
Date: Sun May 13 18:01:40 2012
New Revision: 16294

URL: http://svn.gna.org/viewcvs/relax?rev=16294&view=rev
Log:
Shifted the prompt.base_class._strip_lead() fn to relax_string.strip_lead().


Modified:
    branches/uf_redesign/gui/uf_objects.py
    branches/uf_redesign/prompt/base_class.py
    branches/uf_redesign/prompt/uf_objects.py
    branches/uf_redesign/relax_string.py

Modified: branches/uf_redesign/gui/uf_objects.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/uf_objects.py?rev=16294&r1=16293&r2=16294&view=diff
==============================================================================
--- branches/uf_redesign/gui/uf_objects.py (original)
+++ branches/uf_redesign/gui/uf_objects.py Sun May 13 18:01:40 2012
@@ -33,8 +33,8 @@
 # relax module imports.
 import arg_check
 from graphics import fetch_icon
-from prompt.base_class import _strip_lead
 from relax_errors import AllRelaxErrors, RelaxError
+from relax_string import strip_lead
 from user_functions.data import Uf_info; uf_info = Uf_info()
 
 # relax GUI imports.
@@ -274,7 +274,7 @@
         """
 
         # First strip whitespace.
-        stripped_text = _strip_lead(text)
+        stripped_text = strip_lead(text)
 
         # Remove the first characters if newlines.
         while True:
@@ -615,7 +615,7 @@
         yield doc[0], 'title'
 
         # Strip the leading whitespace, if needed.
-        doc[1] = _strip_lead(doc[1])
+        doc[1] = strip_lead(doc[1])
 
         # Split up the description.
         docstring_lines = split(doc[1], "\n")

Modified: branches/uf_redesign/prompt/base_class.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/base_class.py?rev=16294&r1=16293&r2=16294&view=diff
==============================================================================
--- branches/uf_redesign/prompt/base_class.py (original)
+++ branches/uf_redesign/prompt/base_class.py Sun May 13 18:01:40 2012
@@ -32,6 +32,7 @@
 # relax module imports.
 import ansi
 import help
+from relax_string import strip_lead
 from status import Status; status = Status()
 from string import split, strip
 
@@ -145,7 +146,7 @@
     """
 
     # First strip whitespace.
-    stripped_text = _strip_lead(text)
+    stripped_text = strip_lead(text)
 
     # Remove the first characters if newlines.
     while True:
@@ -177,41 +178,3 @@
 
     # Return the formatted text.
     return new_text
-
-
-def _strip_lead(text):
-    """Strip the leading whitespace from the given text.
-
-    @param text:    The text to strip the leading whitespace from.
-    @type text:     str
-    @return:        The text with leading whitespace removed.
-    @rtype:         str
-    """
-
-    # Split by newline.
-    lines = split(text, '\n')
-
-    # Find the minimum whitespace.
-    min_white = 1000
-    for line in lines:
-        # Empty lines.
-        if strip(line) == '':
-            continue
-
-        # Count the whitespace for the current line.
-        num_white = 0
-        for i in range(len(line)):
-            if line[i] != ' ':
-                break
-            num_white = num_white + 1
-
-        # The min value.
-        min_white = min(min_white, num_white)
-
-    # Strip the whitespace.
-    new_text = ''
-    for line in lines:
-        new_text = new_text + line[min_white:] + '\n'
-
-    # Return the new text.
-    return new_text

Modified: branches/uf_redesign/prompt/uf_objects.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/uf_objects.py?rev=16294&r1=16293&r2=16294&view=diff
==============================================================================
--- branches/uf_redesign/prompt/uf_objects.py (original)
+++ branches/uf_redesign/prompt/uf_objects.py Sun May 13 18:01:40 2012
@@ -25,9 +25,10 @@
 
 # relax module imports.
 import arg_check
-from prompt.base_class import _bold_text, _build_subtitle, _format_text, 
_strip_lead
+from prompt.base_class import _bold_text, _build_subtitle, _format_text
 from prompt.help import relax_class_help
 from relax_errors import RelaxError
+from relax_string import strip_lead
 from status import Status; status = Status()
 
 
@@ -52,7 +53,7 @@
 
         # Add a description to the help string.
         if hasattr(self, '__description__'):
-            self.__relax_help__ += "\n\n%s" % 
_strip_lead(self.__description__)
+            self.__relax_help__ += "\n\n%s" % 
strip_lead(self.__description__)
 
 
     def __repr__(self):

Modified: branches/uf_redesign/relax_string.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/relax_string.py?rev=16294&r1=16293&r2=16294&view=diff
==============================================================================
--- branches/uf_redesign/relax_string.py (original)
+++ branches/uf_redesign/relax_string.py Sun May 13 18:01:40 2012
@@ -30,6 +30,44 @@
 SUBSECTION = 1
 PARAGRAPH = 0
 LIST = 10
+
+
+def strip_lead(text):
+    """Strip the leading whitespace from the given text.
+
+    @param text:    The text to strip the leading whitespace from.
+    @type text:     str
+    @return:        The text with leading whitespace removed.
+    @rtype:         str
+    """
+
+    # Split by newline.
+    lines = split(text, '\n')
+
+    # Find the minimum whitespace.
+    min_white = 1000
+    for line in lines:
+        # Empty lines.
+        if strip(line) == '':
+            continue
+
+        # Count the whitespace for the current line.
+        num_white = 0
+        for i in range(len(line)):
+            if line[i] != ' ':
+                break
+            num_white = num_white + 1
+
+        # The min value.
+        min_white = min(min_white, num_white)
+
+    # Strip the whitespace.
+    new_text = ''
+    for line in lines:
+        new_text = new_text + line[min_white:] + '\n'
+
+    # Return the new text.
+    return new_text
 
 
 def to_docstring(data):




Related Messages


Powered by MHonArc, Updated Sun May 13 18:20:02 2012