(self, url, project_name)
return result
See if a URL is a candidate for a download URL for a project (the URL
        has typically been scraped from an HTML page).

        If it is, a dictionary is returned with keys "name", "version",
        "filename" and "url"; otherwise, None is returned.
See if a URL is a candidate for a download URL for a project (the URL
        has typically been scraped from an HTML page).
See if a URL is a candidate for a download URL for a project ( the URL has typically been scraped from an HTML page ) .
def convert_url_to_download_info(self, url, project_name):
        """
        See if a URL is a candidate for a download URL for a project (the URL
        has typically been scraped from an HTML page).

        If it is, a dictionary is returned with keys "name", "version",
        "filename" and "url"; otherwise, None is returned.
        """
        def same_project(name1, name2):
            return normalize_name(name1) == normalize_name(name2)

        result = None
        scheme, netloc, path, params, query, frag = urlparse(url)
        if frag.lower().startswith('egg='):  # pragma: no cover
            logger.debug('%s: version hint in fragment: %r',
                         project_name, frag)
        m = HASHER_HASH.match(frag)
        if m:
            algo, digest = m.groups()
        else:
            algo, digest = None, None
        origpath = path
        if path and path[-1] == '/':  # pragma: no cover
            path = path[:-1]
        if path.endswith('.whl'):
            try:
                wheel = Wheel(path)
                if not is_compatible(wheel, self.wheel_tags):
                    logger.debug('Wheel not compatible: %s', path)
                else:
                    if project_name is None:
                        include = True
                    else:
                        include = same_project(wheel.name, project_name)
                    if include:
                        result = {
                            'name': wheel.name,
                            'version': wheel.version,
                            'filename': wheel.filename,
                            'url': urlunparse((scheme, netloc, origpath,
                                               params, query, '')),
                            'python-version': ', '.join(
                                ['.'.join(list(v[2:])) for v in wheel.pyver]),
                        }
            except Exception as e:  # pragma: no cover
                logger.warning('invalid path for wheel: %s', path)
        elif not path.endswith(self.downloadable_extensions):  # pragma: no cover
            logger.debug('Not downloadable: %s', path)
        else:  # downloadable extension
            path = filename = posixpath.basename(path)
            for ext in self.downloadable_extensions:
                if path.endswith(ext):
                    path = path[:-len(ext)]
                    t = self.split_filename(path, project_name)
                    if not t:  # pragma: no cover
                        logger.debug('No match for project/version: %s', path)
                    else:
                        name, version, pyver = t
                        if not project_name or same_project(project_name, name):
                            result = {
                                'name': name,
                                'version': version,
                                'filename': filename,
                                'url': urlunparse((scheme, netloc, origpath,
                                                   params, query, '')),
                                #'packagetype': 'sdist',
                            }
                            if pyver:  # pragma: no cover
                                result['python-version'] = pyver
                    break
        if result and algo:
            result['%s_digest' % algo] = digest
        return result
def convert_url_to_download_info ( self , url , project_name ) : def same_project ( name1 , name2 ) : return normalize_name ( name1 ) == normalize_name ( name2 ) result = None scheme , netloc , path , params , query , frag = urlparse ( url ) if frag . lower ( ) . startswith ( 'egg=' ) : # pragma: no cover logger . debug ( '%s: version hint in fragment: %r' , project_name , frag ) m = HASHER_HASH . match ( frag ) if m : algo , digest = m . groups ( ) else : algo , digest = None , None origpath = path if path and path [ - 1 ] == '/' : # pragma: no cover path = path [ : - 1 ] if path . endswith ( '.whl' ) : try : wheel = Wheel ( path ) if not is_compatible ( wheel , self . wheel_tags ) : logger . debug ( 'Wheel not compatible: %s' , path ) else : if project_name is None : include = True else : include = same_project ( wheel . name , project_name ) if include : result = { 'name' : wheel . name , 'version' : wheel . version , 'filename' : wheel . filename , 'url' : urlunparse ( ( scheme , netloc , origpath , params , query , '' ) ) , 'python-version' : ', ' . join ( [ '.' . join ( list ( v [ 2 : ] ) ) for v in wheel . pyver ] ) , } except Exception as e : # pragma: no cover logger . warning ( 'invalid path for wheel: %s' , path ) elif not path . endswith ( self . downloadable_extensions ) : # pragma: no cover logger . debug ( 'Not downloadable: %s' , path ) else : # downloadable extension path = filename = posixpath . basename ( path ) for ext in self . downloadable_extensions : if path . endswith ( ext ) : path = path [ : - len ( ext ) ] t = self . split_filename ( path , project_name ) if not t : # pragma: no cover logger . debug ( 'No match for project/version: %s' , path ) else : name , version , pyver = t if not project_name or same_project ( project_name , name ) : result = { 'name' : name , 'version' : version , 'filename' : filename , 'url' : urlunparse ( ( scheme , netloc , origpath , params , query , '' ) ) , #'packagetype': 'sdist', } if pyver : # pragma: no cover result [ 'python-version' ] = pyver break if result and algo : result [ '%s_digest' % algo ] = digest return result