def from_text(cls, text):
        """Whereas the :class:`URL` constructor is useful for constructing
        URLs from parts, :meth:`~URL.from_text` supports parsing whole
        URLs from their string form::

           >>> URL.from_text(u'http://example.com')
           URL.from_text(u'http://example.com')
           >>> URL.from_text(u'?a=b&x=y')
           URL.from_text(u'?a=b&x=y')

        As you can see above, it's also used as the :func:`repr` of
        :class:`URL` objects. The natural counterpart to
        :func:`~URL.to_text()`. This method only accepts *text*, so be
        sure to decode those bytestrings.

        Args:
           text (unicode): A valid URL string.

        Returns:
           URL: The structured object version of the parsed string.

        .. note::

            Somewhat unexpectedly, URLs are a far more permissive
            format than most would assume. Many strings which don't
            look like URLs are still valid URLs. As a result, this
            method only raises :class:`URLParseError` on invalid port
            and IPv6 values in the host portion of the URL.

        """
        um = _URL_RE.match(_textcheck('text', text))
        try:
            gs = um.groupdict()
        except AttributeError:
            raise URLParseError('could not parse url: %r' % text)

        au_text = gs['authority'] or u''
        au_m = _AUTHORITY_RE.match(au_text)
        try:
            au_gs = au_m.groupdict()
        except AttributeError:
            raise URLParseError('invalid authority %r in url: %r'
                                % (au_text, text))
        if au_gs['bad_host']:
            raise URLParseError('invalid host %r in url: %r'
                               % (au_gs['bad_host'], text))

        userinfo = au_gs['userinfo'] or u''

        host = au_gs['ipv6_host'] or au_gs['plain_host']
        port = au_gs['port']
        if port is not None:
            try:
                port = int(port)
            except ValueError:
                if not port:  # TODO: excessive?
                    raise URLParseError('port must not be empty: %r' % au_text)
                raise URLParseError('expected integer for port, not %r' % port)

        scheme = gs['scheme'] or u''
        fragment = gs['fragment'] or u''
        uses_netloc = bool(gs['_netloc_sep'])

        if gs['path']:
            path = gs['path'].split(u"/")
            if not path[0]:
                path.pop(0)
                rooted = True
            else:
                rooted = False
        else:
            path = ()
            rooted = bool(au_text)
        if gs['query']:
            query = ((qe.split(u"=", 1) if u'=' in qe else (qe, None))
                     for qe in gs['query'].split(u"&"))
        else:
            query = ()
        return cls(scheme, host, path, query, fragment, port,
                   rooted, userinfo, uses_netloc)
Whereas the :class:`URL` constructor is useful for constructing
        URLs from parts, :meth:`~URL.from_text` supports parsing whole
        URLs from their string form::

           >>> URL.from_text(u'http://example.com')
           URL.from_text(u'http://example.com')
           >>> URL.from_text(u'?a=b&x=y')
           URL.from_text(u'?a=b&x=y')

        As you can see above, it's also used as the :func:`repr` of
        :class:`URL` objects. The natural counterpart to
        :func:`~URL.to_text()`. This method only accepts *text*, so be
        sure to decode those bytestrings.

        Args:
           text (unicode): A valid URL string.

        Returns:
           URL: The structured object version of the parsed string.

        .. note::

            Somewhat unexpectedly, URLs are a far more permissive
            format than most would assume. Many strings which don't
            look like URLs are still valid URLs. As a result, this
            method only raises :class:`URLParseError` on invalid port
            and IPv6 values in the host portion of the URL.

        
stackoverflow/venv/lib/python3.6/site-packages/hyperlink/_url.py