class_docstr: Validate an URL.
  
  Example::
  
      parser = reqparse.RequestParser()
      parser.add_argument('url', type=inputs.URL(schemes=['http', 'https']))
  
  Input to the ``URL`` argument will be rejected
  if it does not match an URL with specified constraints.
  If ``check`` is True it will also be rejected if the domain does not exists.
  
  :param bool check: Check the domain exists (perform a DNS resolution)
  :param bool ip: Allow IP (both ipv4/ipv6) as domain
  :param bool local: Allow localhost (both string or ip) as domain
  :param bool port: Allow a port to be present
  :param bool auth: Allow authentication to be present
  :param list|tuple schemes: Restrict valid schemes to this list
  :param list|tuple domains: Restrict valid domains to this list
  :param list|tuple exclude: Exclude some domains
class_docstr_tok: ["Validate","an","URL",".","Example",":",":","parser","=","reqparse.RequestParser","(",")","parser.add_argument","(","'url","'",",","type=inputs.URL","(","schemes=","[","'http","'",",","'https","'","]",")",")","Input","to","the","``","URL","``","argument","will","be","rejected","if","it","does","not","match","an","URL","with","specified","constraints",".","If","``","check","``","is","True","it","will","also","be","rejected","if","the","domain","does","not","exists",".",":","param","bool","check",":","Check","the","domain","exists","(","perform","a","DNS","resolution",")",":","param","bool","ip",":","Allow","IP","(","both","ipv4\/ipv6",")","as","domain",":","param","bool","local",":","Allow","localhost","(","both","string","or","ip",")","as","domain",":","param","bool","port",":","Allow","a","port","to","be","present",":","param","bool","auth",":","Allow","authentication","to","be","present",":","param","list|tuple","schemes",":","Restrict","valid","schemes","to","this","list",":","param","list|tuple","domains",":","Restrict","valid","domains","to","this","list",":","param","list|tuple","exclude",":","Exclude","some","domains"]
code: def __call__(self, value):
      parsed = urlparse(value)
      netloc_match = netloc_regex.match(parsed.netloc)
      if not all((parsed.scheme, parsed.netloc)):
          if netloc_regex.match(
              parsed.netloc
              or parsed.path.split("/", 1)[0].split("?", 1)[0]
          ):
              self.error(value, "Did you mean: http://{0}")
          self.error(value)
      if (
          parsed.scheme
          and self.schemes
          and parsed.scheme not in self.schemes
      ):
          self.error(value, "Protocol is not allowed")
      if not netloc_match:
          self.error(value)
      data = netloc_match.groupdict()
      if data["ipv4"] or data["ipv6"]:
          if not self.ip:
              self.error(value, "IP is not allowed")
          else:
              try:
                  ip(data["ipv4"] or data["ipv6"])
              except ValueError as e:
                  self.error(value, str(e))
          if not self.local:
              if data["ipv4"] and data["ipv4"].startswith("127."):
                  self.error(value, "Localhost is not allowed")
              elif data["ipv6"] == "::1":
                  self.error(value, "Localhost is not allowed")
          if self.check:
              pass
      if data["auth"] and not self.auth:
          self.error(value, "Authentication is not allowed")
      if data["localhost"] and not self.local:
          self.error(value, "Localhost is not allowed")
      if data["port"]:
          if not self.port:
              self.error(value, "Custom port is not allowed")
          else:
              port = int(data["port"])
              if not 0 < port < 65535:
                  self.error(value, "Port is out of range")
      if data["domain"]:
          if self.domains and data["domain"] not in self.domains:
              self.error(value, "Domain is not allowed")
          elif self.exclude and data["domain"] in self.exclude:
              self.error(value, "Domain is not allowed")
          if self.check:
              try:
                  socket.getaddrinfo(data["domain"], None)
              except socket.error:
                  self.error(value, "Domain does not exists")
      return value
  
imports: from __future__ import unicode_literals
  import re
  import socket
  from datetime import datetime, time, timedelta
  from email.utils import parsedate_tz, mktime_tz
  from six.moves.urllib.parse import urlparse
  import aniso8601
  import pytz
label_desc: Use image node_id 3 for calling the URL obj's underlying member method code with example usage: obj.__call__(value) and returns: value