def validate_port_or_colon_separated_port_range(port_range):
 if (port_range.count(':') > 1):
  raise ValidationError(_('One colon allowed in port range'))
 ports = port_range.split(':')
 for port in ports:
  validate_port_range(port)

def validate_port_or_colon_separated_port_range ( port_range ) : if ( port_range . count ( ':' ) > 1 ) : raise ValidationError ( _ ( 'One colon allowed in port range' ) ) ports = port_range . split ( ':' ) for port in ports : validate_port_range ( port )
accepts a port number or a single-colon separated range .