#NEWLINE# def IP( ipaddress , comment = '' , token = '' ) : #NEWLINE# #INDENT# "Take an ip string and return an object of the correct type.\n\n  Args:\n    ip_string: the ip address.\n    comment:: option comment field\n    token:: option token name where this address was extracted from\n\n  Returns:\n    ipaddr.IPv4 or ipaddr.IPv6 object or raises ValueError.\n\n  Raises:\n    ValueError: if the string passed isn't either a v4 or a v6 address.\n\n  Notes:\n    this is sort of a poor-mans factory method.\n  " #NEWLINE# a = ipaddr . IPNetwork ( ipaddress ) #NEWLINE# if ( a . version == 4 ) : #NEWLINE# #INDENT# return IPv4 ( ipaddress , comment , token ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( a . version == 6 ) : #NEWLINE# #INDENT# return IPv6 ( ipaddress , comment , token )