comparison MoinMoin/wikiutil.py @ 2527:4f6f7e56eb40

fix error message for get_* (arg parser)
author Johannes Berg <johannes AT sipsolutions DOT net>
date Mon, 23 Jul 2007 11:36:37 +0200
parents 6de0e14591f7
children 1ae621d83c5b
comparison
equal deleted inserted replaced
2526:860e7bf6c4cc 2527:4f6f7e56eb40
1351 return False 1351 return False
1352 elif arg in [u'1', u'true', u'yes']: 1352 elif arg in [u'1', u'true', u'yes']:
1353 return True 1353 return True
1354 else: 1354 else:
1355 if name: 1355 if name:
1356 raise ValueError(_('Argument "%s" must be a boolean value') % name) 1356 raise ValueError(
1357 _('Argument "%s" must be a boolean value, not "%s"') % (
1358 name, arg))
1357 else: 1359 else:
1358 raise ValueError(_('Argument must be a boolean value')) 1360 raise ValueError(
1361 _('Argument must be a boolean value, not "%s"') % arg)
1359 1362
1360 1363
1361 def get_int(request, arg, name=None, default=None): 1364 def get_int(request, arg, name=None, default=None):
1362 """ 1365 """
1363 For use with values returned from parse_quoted_separated or given 1366 For use with values returned from parse_quoted_separated or given
1380 raise TypeError('Argument must be None or unicode') 1383 raise TypeError('Argument must be None or unicode')
1381 try: 1384 try:
1382 return int(arg) 1385 return int(arg)
1383 except ValueError: 1386 except ValueError:
1384 if name: 1387 if name:
1385 raise ValueError(_('Argument "%s" must be an integer value') % name) 1388 raise ValueError(
1389 _('Argument "%s" must be an integer value, not "%s"') % (
1390 name, arg))
1386 else: 1391 else:
1387 raise ValueError(_('Argument must be an integer value')) 1392 raise ValueError(
1393 _('Argument must be an integer value, not "%s"') % arg)
1388 1394
1389 1395
1390 def get_float(request, arg, name=None, default=None): 1396 def get_float(request, arg, name=None, default=None):
1391 """ 1397 """
1392 For use with values returned from parse_quoted_separated or given 1398 For use with values returned from parse_quoted_separated or given
1409 try: 1415 try:
1410 return float(arg) 1416 return float(arg)
1411 except ValueError: 1417 except ValueError:
1412 if name: 1418 if name:
1413 raise ValueError( 1419 raise ValueError(
1414 _('Argument "%s" must be a floating point value') % name) 1420 _('Argument "%s" must be a floating point value, not "%s"') % (
1421 name, arg))
1415 else: 1422 else:
1416 raise ValueError(_('Argument must be a floating point value')) 1423 raise ValueError(
1424 _('Argument must be a boolean value, not "%s"') % arg)
1417 1425
1418 1426
1419 def get_unicode(request, arg, name=None, default=None): 1427 def get_unicode(request, arg, name=None, default=None):
1420 """ 1428 """
1421 For use with values returned from parse_quoted_separated or given 1429 For use with values returned from parse_quoted_separated or given