mailr9383 - /1.3/prompt/check.py


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

Header


Content

Posted by edward on August 24, 2009 - 20:14:
Author: bugman
Date: Mon Aug 24 20:14:17 2009
New Revision: 9383

URL: http://svn.gna.org/viewcvs/relax?rev=9383&view=rev
Log:
Modified is_num_list() to check for empty lists.


Modified:
    1.3/prompt/check.py

Modified: 1.3/prompt/check.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/prompt/check.py?rev=9383&r1=9382&r2=9383&view=diff
==============================================================================
--- 1.3/prompt/check.py (original)
+++ 1.3/prompt/check.py Mon Aug 24 20:14:17 2009
@@ -195,7 +195,7 @@
             raise RelaxNoneNumError(name, arg)
 
 
-def is_num_list(arg, name, size=None, can_be_none=False):
+def is_num_list(arg, name, size=None, can_be_none=False, can_be_empty=False):
     """Test if the argument is a list of numbers.
 
     @param arg:                 The argument.
@@ -206,6 +206,8 @@
     @type size:                 None or int
     @keyword can_be_none:       A flag specifying if the argument can be 
none.
     @type can_be_none:          bool
+    @keyword can_be_empty:      A flag which if True allows the list to be 
empty.
+    @type can_be_empty:         bool
     @raise RelaxListError:      If not a list.
     @raise RelaxListNumError:   If not a list of numbers.
     """
@@ -227,6 +229,13 @@
             raise RelaxNoneListNumError(name, arg, size)
         else:
             raise RelaxListNumError(name, arg, size)
+
+    # Fail if empty.
+    if not can_be_empty and arg == []:
+        if can_be_none:
+            raise RelaxNoneListNumError(name, arg)
+        else:
+            raise RelaxListNumError(name, arg)
 
     # Fail if not numbers.
     for i in range(len(arg)):




Related Messages


Powered by MHonArc, Updated Mon Aug 24 20:40:07 2009