def int_validator(value, context):
 if (value is None):
  return None
 if (hasattr(value, 'strip') and (not value.strip())):
  return None
 try:
  (whole, part) = divmod(value, 1)
 except TypeError:
  try:
   return int(value)
  except ValueError:
   pass
 else:
  if (not part):
   try:
    return int(whole)
   except TypeError:
    pass
 raise Invalid(_('Invalid integer'))

def int_validator ( value , context ) : if ( value is None ) : return None if ( hasattr ( value , 'strip' ) and ( not value . strip ( ) ) ) : return None try : ( whole , part ) = divmod ( value , 1 ) except TypeError : try : return int ( value ) except ValueError : pass else : if ( not part ) : try : return int ( whole ) except TypeError : pass raise Invalid ( _ ( 'Invalid integer' ) )
return an integer for value .