How to use the distlib.compat.urlparse function in distlib

To help you get started, we’ve selected a few distlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cloudfoundry / python-buildpack / vendor / pip-1.5.4 / pip / _vendor / distlib / index.py View on Github external
def check_credentials(self):
        """
        Check that ``username`` and ``password`` have been set, and raise an
        exception if not.
        """
        if self.username is None or self.password is None:
            raise DistlibException('username and password must be set')
        pm = HTTPPasswordMgr()
        _, netloc, _, _, _, _ = urlparse(self.url)
        pm.add_password(self.realm, netloc, self.username, self.password)
        self.password_handler = HTTPBasicAuthHandler(pm)
github ansible / awx / awx / lib / site-packages / pip / _vendor / distlib / index.py View on Github external
def check_credentials(self):
        """
        Check that ``username`` and ``password`` have been set, and raise an
        exception if not.
        """
        if self.username is None or self.password is None:
            raise DistlibException('username and password must be set')
        pm = HTTPPasswordMgr()
        _, netloc, _, _, _, _ = urlparse(self.url)
        pm.add_password(self.realm, netloc, self.username, self.password)
        self.password_handler = HTTPBasicAuthHandler(pm)
github clarete / curdling / curdling / services / downloader.py View on Github external
def get_page(self, url):
        # http://peak.telecommunity.com/DevCenter/EasyInstall#package-index-api
        scheme, netloc, path, _, _, _ = compat.urlparse(url)
        if scheme == 'file' and os.path.isdir(url2pathname(path)):
            url = compat.urljoin(ensure_slash(url), 'index.html')

        # The `retrieve()` method follows any eventual redirects, so the
        # initial url might be different from the final one
        try:
            response, final_url = http_retrieve(self.opener, url)
        except urllib3.exceptions.MaxRetryError:
            return

        content_type = response.headers.get('content-type', '')
        if locators.HTML_CONTENT_TYPE.match(content_type):
            data = response.data
            encoding = response.headers.get('content-encoding')
            if encoding:
                decoder = self.decoders[encoding]   # fail if not found
github clarete / curdling / curdling / services / downloader.py View on Github external
def update_url_credentials(self, base_url, other_url):
        base = compat.urlparse(base_url)
        other = compat.urlparse(other_url)

        # If they're not from the same server, we return right away without
        # trying to update anything
        if base.hostname != other.hostname or base.password != other.password:
            return other.geturl()

        # Updating credentials only if the target URL doesn't have the data
        # that we want to set
        if base.username and not other.username:
            other.username = base.username
        if base.password and not other.password:
            other.password = base.password
        return other.geturl()
github clarete / curdling / curdling / services / downloader.py View on Github external
def update_url_credentials(self, base_url, other_url):
        base = compat.urlparse(base_url)
        other = compat.urlparse(other_url)

        # If they're not from the same server, we return right away without
        # trying to update anything
        if base.hostname != other.hostname or base.password != other.password:
            return other.geturl()

        # Updating credentials only if the target URL doesn't have the data
        # that we want to set
        if base.username and not other.username:
            other.username = base.username
        if base.password and not other.password:
            other.password = base.password
        return other.geturl()