#NEWLINE# def provides_distribution( self , name , version = None ) : #NEWLINE# #INDENT# '\n        Iterates over all distributions to find which distributions provide *name*.\n        If a *version* is provided, it will be used to filter the results.\n\n        This function only returns the first result found, since no more than\n        one values are expected. If the directory is not found, returns ``None``.\n\n        :parameter version: a version specifier that indicates the version\n                            required, conforming to the format in ``PEP-345``\n\n        :type name: string\n        :type version: string\n        ' #NEWLINE# matcher = None #NEWLINE# if ( not ( version is None ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# matcher = self . _scheme . matcher ( ( '%s (%s)' % ( name , version ) ) ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# raise DistlibException ( ( 'invalid name or version: %r, %r' % ( name , version ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# for dist in self . get_distributions ( ) : #NEWLINE# #INDENT# provided = dist . provides #NEWLINE# for p in provided : #NEWLINE# #INDENT# ( p_name , p_ver ) = parse_name_and_version ( p ) #NEWLINE# if ( matcher is None ) : #NEWLINE# #INDENT# if ( p_name == name ) : #NEWLINE# #INDENT# ( yield name ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( p_name == name ) and matcher . match ( p_ver ) ) : #NEWLINE# #INDENT# ( yield dist ) #NEWLINE# break