mailr16600 - in /branches/uf_redesign/prompt: uf_docstring.py uf_objects.py


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

Header


Content

Posted by edward on June 02, 2012 - 19:26:
Author: bugman
Date: Sat Jun  2 19:26:07 2012
New Revision: 16600

URL: http://svn.gna.org/viewcvs/relax?rev=16600&view=rev
Log:
The prompt UI help string construction code is now handling the new Uf_tables 
singleton.


Modified:
    branches/uf_redesign/prompt/uf_docstring.py
    branches/uf_redesign/prompt/uf_objects.py

Modified: branches/uf_redesign/prompt/uf_docstring.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/uf_docstring.py?rev=16600&r1=16599&r2=16600&view=diff
==============================================================================
--- branches/uf_redesign/prompt/uf_docstring.py (original)
+++ branches/uf_redesign/prompt/uf_docstring.py Sat Jun  2 19:26:07 2012
@@ -33,6 +33,7 @@
 import help
 from relax_string import strip_lead
 from status import Status; status = Status()
+from user_functions.data import Uf_tables; uf_tables = Uf_tables()
 
 
 def bold_text(text):
@@ -88,29 +89,34 @@
     return new
 
 
-def create_table(table, spacing=True):
+def create_table(label, spacing=True):
     """Format and return the table as text.
 
-    @param table:       The table data.
-    @type table:        list of lists of str
+    @param label:       The unique table label.
+    @type label:        str
     @keyword spacing:   A flag which if True will cause empty rows to be 
placed between elements.
     @type spacing:      bool
     @return:            The formatted table.
     @rtype:             str
     """
 
+    # Get the table.
+    table = uf_tables.get_table(label)
+
     # Initialise some variables.
     text = ''
-    num_rows = len(table)
-    num_cols = len(table[0])
+    num_rows = len(table.cells)
+    num_cols = len(table.headings)
 
     # The column widths.
-    widths = [0] * num_cols
-    for i in range(len(table)):
+    widths = []
+    for j in range(num_cols):
+        widths.append(len(table.headings[j]))
+    for i in range(num_rows):
         for j in range(num_cols):
             # The element is larger than the previous.
-            if len(table[i][j]) > widths[j]:
-                widths[j] = len(table[i][j])
+            if len(table.cells[i][j]) > widths[j]:
+                widths[j] = len(table.cells[i][j])
 
     # The free space for the text.
     used = 0
@@ -194,13 +200,13 @@
     # The header.
     text += "_" * total_width + "\n"    # Top rule.
     text += table_line(widths=new_widths)    # Blank line.
-    text += table_line(text=table[0], widths=new_widths)    # The headers.
+    text += table_line(text=table.headings, widths=new_widths)    # The 
headings.
     text += table_line(widths=new_widths, bottom=True)    # Middle rule.
 
     # The table contents.
-    for i in range(1, num_rows):
+    for i in range(num_rows):
         # Column text, with wrapping.
-        col_text = [table[i]]
+        col_text = [table.cells[i]]
         num_lines = 1
         for j in range(num_cols):
             if col_wrap[j]:

Modified: branches/uf_redesign/prompt/uf_objects.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/uf_objects.py?rev=16600&r1=16599&r2=16600&view=diff
==============================================================================
--- branches/uf_redesign/prompt/uf_objects.py (original)
+++ branches/uf_redesign/prompt/uf_objects.py Sat Jun  2 19:26:07 2012
@@ -320,7 +320,7 @@
                 doc += build_subtitle(self._desc[i].get_title())
 
                 # Loop over the elements.
-                for type, element, format in 
self._desc[i].element_loop(format=True):
+                for type, element in self._desc[i].element_loop():
                     # A paragraph or verbatim text.
                     if type == 'paragraph':
                         doc += format_text(element) + '\n'
@@ -353,7 +353,7 @@
 
                     # A table.
                     elif type == 'table':
-                        doc += create_table(element, spacing=format) + '\n'
+                        doc += create_table(element) + '\n'
 
                     # A prompt example.
                     elif type == 'prompt':




Related Messages


Powered by MHonArc, Updated Sat Jun 02 19:40:02 2012