def fix_uri(self, text):
        """
        Validates a text as URL format, also adjusting necessary stuff for a
        clearer URL that will be fetched here.

        Code based on Django source:
        https://code.djangoproject.com/browser/django/trunk/django/forms/
        fields.py?rev=17430#L610

        Arguments:

            * text: the URL string that is to be validated and fixed
        """
        if not text:
            raise exception.UrlException(text, _("URL can not be blank"))
        try:
            url_fields = list(urlparse.urlsplit(text))
        except __HOLE__:
            raise exception.UrlException(text, _("URL does not seem valid"))

        if not url_fields[0]:
            # If no URL scheme given, assume http://
            url_fields[0] = 'http'
        if not url_fields[1]:
            # Assume that if no domain is provided, that the path segment
            # contains the domain.
            url_fields[1] = url_fields[2]
            url_fields[2] = ''
            # Rebuild the url_fields list, since the domain segment may now
            # contain the path too.
            try:
                url_fields = list(urlparse.urlsplit(
                    urlparse.urlunsplit(url_fields)))
            except ValueError:
                raise exception.UrlException(text,
                    _("URL does not seem valid"))

        if not url_fields[2]:
            # the path portion may need to be added before query params
            url_fields[2] = '/'
        return urlparse.urlunsplit(url_fields)
dataset/ETHPy150Open brunobraga/termsaver/termsaverlib/screen/helper/urlfetcher.py/URLFetcherHelperBase.fix_uri