def convert_url_to_download_info(self, url, project_name):
def same_project(name1, name2):<EOL><INDENT>name1, name2 = name1.lower(), name2.lower()<EOL>if name1 == name2:<EOL><INDENT>result = True<EOL><DEDENT>else:<EOL><INDENT>result = name1.replace('<STR_LIT:_>', '<STR_LIT:->') == name2.replace('<STR_LIT:_>', '<STR_LIT:->')<EOL><DEDENT>return result<EOL><DEDENT>result = None<EOL>scheme, netloc, path, params, query, frag = urlparse(url)<EOL>if frag.lower().startswith('<STR_LIT>'):<EOL><INDENT>logger.debug('<STR_LIT>',<EOL>project_name, frag)<EOL><DEDENT>m = HASHER_HASH.match(frag)<EOL>if m:<EOL><INDENT>algo, digest = m.groups()<EOL><DEDENT>else:<EOL><INDENT>algo, digest = None, None<EOL><DEDENT>origpath = path<EOL>if path and path[-<NUM_LIT:1>] == '<STR_LIT:/>':<EOL><INDENT>path = path[:-<NUM_LIT:1>]<EOL><DEDENT>if path.endswith('<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>wheel = Wheel(path)<EOL>if is_compatible(wheel, self.wheel_tags):<EOL><INDENT>if project_name is None:<EOL><INDENT>include = True<EOL><DEDENT>else:<EOL><INDENT>include = same_project(wheel.name, project_name)<EOL><DEDENT>if include:<EOL><INDENT>result = {<EOL>'<STR_LIT:name>': wheel.name,<EOL>'<STR_LIT:version>': wheel.version,<EOL>'<STR_LIT:filename>': wheel.filename,<EOL>'<STR_LIT:url>': urlunparse((scheme, netloc, origpath,<EOL>params, query, '<STR_LIT>')),<EOL>'<STR_LIT>': '<STR_LIT:U+002CU+0020>'.join(<EOL>['<STR_LIT:.>'.join(list(v[<NUM_LIT:2>:])) for v in wheel.pyver]),<EOL>}<EOL><DEDENT><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>logger.warning('<STR_LIT>', path)<EOL><DEDENT><DEDENT>elif path.endswith(self.downloadable_extensions):<EOL><INDENT>path = filename = posixpath.basename(path)<EOL>for ext in self.downloadable_extensions:<EOL><INDENT>if path.endswith(ext):<EOL><INDENT>path = path[:-len(ext)]<EOL>t = self.split_filename(path, project_name)<EOL>if not t:<EOL><INDENT>logger.debug('<STR_LIT>', path)<EOL><DEDENT>else:<EOL><INDENT>name, version, pyver = t<EOL>if not project_name or same_project(project_name, name):<EOL><INDENT>result = {<EOL>'<STR_LIT:name>': name,<EOL>'<STR_LIT:version>': version,<EOL>'<STR_LIT:filename>': filename,<EOL>'<STR_LIT:url>': urlunparse((scheme, netloc, origpath,<EOL>params, query, '<STR_LIT>')),<EOL>}<EOL>if pyver:<EOL><INDENT>result['<STR_LIT>'] = pyver<EOL><DEDENT><DEDENT><DEDENT>break<EOL><DEDENT><DEDENT><DEDENT>if result and algo:<EOL><INDENT>result['<STR_LIT>' % algo] = digest<EOL><DEDENT>return result<EOL>
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.