#NEWLINE# def ip_address_validators( protocol , unpack_ipv4 ) : #NEWLINE# #INDENT# '\n    Depending on the given parameters returns the appropriate validators for\n    the GenericIPAddressField.\n\n    This code is here, because it is exactly the same for the model and the form field.\n    ' #NEWLINE# if ( ( protocol != 'both' ) and unpack_ipv4 ) : #NEWLINE# #INDENT# raise ValueError ( "You can only use `unpack_ipv4` if `protocol` is set to 'both'" ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return ip_address_validator_map [ protocol . lower ( ) ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise ValueError ( ( "The protocol '%s' is unknown. Supported: %s" % ( protocol , list ( ip_address_validator_map ) ) ) )