#NEWLINE# def convert_url_to_download_info( self , url , project_name ) : #NEWLINE# #INDENT# '\n        See if a URL is a candidate for a download URL for a project (the URL\n        has typically been scraped from an HTML page).\n\n        If it is, a dictionary is returned with keys "name", "version",\n        "filename" and "url"; otherwise, None is returned.\n        ' #NEWLINE# def same_project( name1 , name2 ) : #NEWLINE# #INDENT# ( name1 , name2 ) = ( name1 . lower ( ) , name2 . lower ( ) ) #NEWLINE# if ( name1 == name2 ) : #NEWLINE# #INDENT# result = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result = ( name1 . replace ( '_' , '-' ) == name2 . replace ( '_' , '-' ) ) #NEWLINE# #UNINDENT# return result #NEWLINE# #UNINDENT# result = None #NEWLINE# ( scheme , netloc , path , params , query , frag ) = urlparse ( url ) #NEWLINE# if frag . lower ( ) . startswith ( 'egg=' ) : #NEWLINE# #INDENT# logger . debug ( '%s: version hint in fragment: %r' , project_name , frag ) #NEWLINE# #UNINDENT# m = HASHER_HASH . match ( frag ) #NEWLINE# if m : #NEWLINE# #INDENT# ( algo , digest ) = m . groups ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( algo , digest ) = ( None , None ) #NEWLINE# #UNINDENT# origpath = path #NEWLINE# if ( path and ( path [ ( - 1 ) ] == '/' ) ) : #NEWLINE# #INDENT# path = path [ : ( - 1 ) ] #NEWLINE# #UNINDENT# if path . endswith ( '.whl' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# wheel = Wheel ( path ) #NEWLINE# if is_compatible ( wheel , self . wheel_tags ) : #NEWLINE# #INDENT# if ( project_name is None ) : #NEWLINE# #INDENT# include = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# include = same_project ( wheel . name , project_name ) #NEWLINE# #UNINDENT# if include : #NEWLINE# #INDENT# result = { #NEWLINE# #INDENT# 'name' : wheel . name , #NEWLINE# 'version' : result . version , #NEWLINE# 'filename' : wheel . filename , #NEWLINE# 'url' : urlunparse ( ( scheme , netloc , origpath , params , query , '' ) ) , #NEWLINE# 'python-version' : ', ' . join ( [ '.' . join ( list ( v [ 2 : ] ) ) for v in wheel . pyver ] ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# logger . warning ( 'invalid path for wheel: %s' , path ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if path . endswith ( self . downloadable_extensions ) : #NEWLINE# #INDENT# path = filename = posixpath . basename ( path ) #NEWLINE# for ext in self . downloadable_extensions : #NEWLINE# #INDENT# if path . endswith ( ext ) : #NEWLINE# #INDENT# path = path [ : ( - len ( ext ) ) ] #NEWLINE# t = self . split_filename ( path , project_name ) #NEWLINE# if ( not t ) : #NEWLINE# #INDENT# logger . debug ( 'No match for project/version: %s' , path ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( name , version , pyver ) = t #NEWLINE# if ( ( not project_name ) or same_project ( project_name , name ) ) : #NEWLINE# #INDENT# result = { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'version' : version , #NEWLINE# 'filename' : filename , #NEWLINE# 'url' : urlunparse ( ( scheme , netloc , origpath , params , query , '' ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# if pyver : #NEWLINE# #INDENT# result [ 'python-version' ] = pyver #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( result and algo ) : #NEWLINE# #INDENT# result [ ( '%s_digest' % algo ) ] = digest #NEWLINE# #UNINDENT# return result