mailr14665 - /1.3/gui/misc.py


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

Header


Content

Posted by edward on September 16, 2011 - 14:42:
Author: bugman
Date: Fri Sep 16 14:42:56 2011
New Revision: 14665

URL: http://svn.gna.org/viewcvs/relax?rev=14665&view=rev
Log:
Created the gui.misc.gui_to_str_or_list() conversion function.


Modified:
    1.3/gui/misc.py

Modified: 1.3/gui/misc.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/gui/misc.py?rev=14665&r1=14664&r2=14665&view=diff
==============================================================================
--- 1.3/gui/misc.py (original)
+++ 1.3/gui/misc.py Fri Sep 16 14:42:56 2011
@@ -245,6 +245,31 @@
     return val
 
 
+def gui_to_str_or_list(string):
+    """Convert the GUI obtained string to a list.
+
+    @param string:  The list in string form.
+    @type string:   str or unicode
+    @return:        The integer or list of integers.
+    @rtype:         int or int list
+    """
+
+    # No value.
+    if string in ['', u'']:
+        return None
+
+    # Try converting to a list.
+    try:
+        val = eval(string)
+
+    # Failure, so return the original value.
+    except NameError:
+        return string
+
+    # Return the list.
+    return val
+
+
 def float_to_gui(num):
     """Convert the float into the GUI string.
 




Related Messages


Powered by MHonArc, Updated Fri Sep 16 15:00:02 2011