(self, netloc)
Params:
          netloc: Network location string, like 'google.com' or
            'user:pass@google.com:99'.
        Raises: ValueError on invalid port or malformed IPv6 address.
Params:
          netloc: Network location string, like 'google.com' or
            'user:pass
Params : netloc : Network location string like google . com or user : pass
def netloc(self, netloc):
        """
        Params:
          netloc: Network location string, like 'google.com' or
            'user:pass@google.com:99'.
        Raises: ValueError on invalid port or malformed IPv6 address.
        """
        # Raises ValueError on malformed IPv6 addresses.
        urllib.parse.urlsplit('http://%s/' % netloc)

        username = password = host = port = None

        if netloc and '@' in netloc:
            userpass, netloc = netloc.split('@', 1)
            if ':' in userpass:
                username, password = userpass.split(':', 1)
            else:
                username = userpass

        if netloc and ':' in netloc:
            # IPv6 address literal.
            if ']' in netloc:
                colonpos, bracketpos = netloc.rfind(':'), netloc.rfind(']')
                if colonpos > bracketpos and colonpos != bracketpos + 1:
                    raise ValueError("Invalid netloc '%s'." % netloc)
                elif colonpos > bracketpos and colonpos == bracketpos + 1:
                    host, port = netloc.rsplit(':', 1)
                else:
                    host = netloc
            else:
                host, port = netloc.rsplit(':', 1)
                host = host
        else:
            host = netloc

        # Avoid side effects by assigning self.port before self.host so
        # that if an exception is raised when assigning self.port,
        # self.host isn't updated.
        self.port = port  # Raises ValueError on invalid port.
        self.host = host
        self.username = None if username is None else unquote(username)
        self.password = None if password is None else unquote(password)
def netloc ( self , netloc ) : # Raises ValueError on malformed IPv6 addresses. urllib . parse . urlsplit ( 'http://%s/' % netloc ) username = password = host = port = None if netloc and '@' in netloc : userpass , netloc = netloc . split ( '@' , 1 ) if ':' in userpass : username , password = userpass . split ( ':' , 1 ) else : username = userpass if netloc and ':' in netloc : # IPv6 address literal. if ']' in netloc : colonpos , bracketpos = netloc . rfind ( ':' ) , netloc . rfind ( ']' ) if colonpos > bracketpos and colonpos != bracketpos + 1 : raise ValueError ( "Invalid netloc '%s'." % netloc ) elif colonpos > bracketpos and colonpos == bracketpos + 1 : host , port = netloc . rsplit ( ':' , 1 ) else : host = netloc else : host , port = netloc . rsplit ( ':' , 1 ) host = host else : host = netloc # Avoid side effects by assigning self.port before self.host so # that if an exception is raised when assigning self.port, # self.host isn't updated. self . port = port # Raises ValueError on invalid port. self . host = host self . username = None if username is None else unquote ( username ) self . password = None if password is None else unquote ( password )