mailr11497 - /1.3/arg_check.py


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

Header


Content

Posted by edward on August 12, 2010 - 16:37:
Author: bugman
Date: Thu Aug 12 16:37:16 2010
New Revision: 11497

URL: http://svn.gna.org/viewcvs/relax?rev=11497&view=rev
Log:
arg_check.is_int_or_int_list() can now allow for None list elements.


Modified:
    1.3/arg_check.py

Modified: 1.3/arg_check.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/arg_check.py?rev=11497&r1=11496&r2=11497&view=diff
==============================================================================
--- 1.3/arg_check.py (original)
+++ 1.3/arg_check.py Thu Aug 12 16:37:16 2010
@@ -138,7 +138,7 @@
         raise RelaxNoneIntError(name, arg)
 
 
-def is_int_or_int_list(arg, name, size=None, can_be_none=False, 
can_be_empty=False):
+def is_int_or_int_list(arg, name, size=None, can_be_none=False, 
can_be_empty=False, none_elements=False):
     """Test if the argument is an integer or a list of integers.
 
     @param arg:                         The argument.
@@ -151,6 +151,8 @@
     @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
+    @keyword none_elements:             A flag which if True allows the list 
to contain None.
+    @type none_elements:                bool
     @raise RelaxIntListIntError:        If not an integer or a list of 
integers.
     @raise RelaxNoneIntListIntError:    If not an integer, a list of 
integers, or None.
     """
@@ -180,8 +182,12 @@
         if not can_be_empty and arg == []:
             fail = True
 
-       # Check the arguments.
+        # Check the arguments.
         for i in range(len(arg)):
+            # None.
+            if arg[i] == None and none_elements:
+                continue
+
             # Check if it is an integer.
             try:
                 is_int(arg[i], name)




Related Messages


Powered by MHonArc, Updated Thu Aug 12 16:40:02 2010