Author: bugman Date: Sun May 13 11:29:54 2012 New Revision: 16260 URL: http://svn.gna.org/viewcvs/relax?rev=16260&view=rev Log: Eliminated the try logic in the arg_check is_*() fns as the raise_error flag can now be used instead. The change at r16136 in the main 1.3 line allows this simplification. Modified: branches/uf_redesign/arg_check.py Modified: branches/uf_redesign/arg_check.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/arg_check.py?rev=16260&r1=16259&r2=16260&view=diff ============================================================================== --- branches/uf_redesign/arg_check.py (original) +++ branches/uf_redesign/arg_check.py Sun May 13 11:29:54 2012 @@ -422,11 +422,8 @@ # An integer if not isinstance(arg, list): - # Check if it is an integer. - try: - is_int(arg, name) - except: - fail = True # Not an integer. + if not is_int(arg, raise_error=False): + fail = True # A list. else: @@ -445,10 +442,8 @@ continue # Check if it is an integer. - try: - is_int(arg[i], name) - except: - fail = True # Not an integer. + if not is_int(arg[i], raise_error=False): + fail = True # Fail. if fail: @@ -683,10 +678,7 @@ # A number. if not isinstance(arg, tuple): - # Check if it is a number. - try: - is_num(arg, name) - except: + if not is_num(arg, raise_error=False): fail = True # Other checks. @@ -701,7 +693,7 @@ # Fail if not numbers. for i in range(len(arg)): - if (not check_float(arg[i]) and not isinstance(arg[i], int)) or isinstance(arg, bool): + if not is_num(arg[i], raise_error=False): fail = True # Fail. @@ -959,15 +951,9 @@ # A number or a string. if not isinstance(arg, list): - # Check if it is a string. - try: - is_str(arg, name) - except: - # Not a string, therefore check if it is a number. - try: - is_num(arg, name) - except: - fail = True # Neither a number or a string. + # Check if it is a string or number. + if not (is_str(arg, raise_error=False) or is_num(arg, raise_error=False)): + fail = True # A list. else: @@ -981,15 +967,8 @@ # Check the arguments. for i in range(len(arg)): - # Check if it is a string. - try: - is_str(arg[i], name) - except: - # Not a string, therefore check if it is a number. - try: - is_num(arg[i], name) - except: - fail = True # Neither a number or a string. + if not (is_str(arg, raise_error=False) or is_num(arg, raise_error=False)): + fail = True # Fail. if fail: @@ -1038,11 +1017,8 @@ # A string. if not isinstance(arg, list): - # Check if it is a string. - try: - is_str(arg, name) - except: - fail = True # Not a string. + if not is_str(arg, raise_error=False): + fail = True # A list. else: @@ -1054,13 +1030,10 @@ if not can_be_empty and arg == []: fail = True - # Check the arguments. + # Check the arguments. for i in range(len(arg)): - # Check if it is a number. - try: - is_num(arg[i], name) - except: - fail = True # Not a number. + if not is_num(arg[i], raise_error=False): + fail = True # Fail. if fail: @@ -1109,11 +1082,8 @@ # A string. if not isinstance(arg, list): - # Check if it is a string. - try: - is_str(arg, name) - except: - fail = True # Not a string. + if not is_str(arg, raise_error=False): + fail = True # A list. else: @@ -1127,11 +1097,8 @@ # Check the arguments. for i in range(len(arg)): - # Check if it is a string. - try: - is_str(arg[i], name) - except: - fail = True # Not a string. + if not is_str(arg[i], raise_error=False): + fail = True # Fail. if fail: