#NEWLINE# def try_to_replace( self , provider , other , problems ) : #NEWLINE# #INDENT# "\n        Attempt to replace one provider with another. This is typically used\n        when resolving dependencies from multiple sources, e.g. A requires\n        (B >= 1.0) while C requires (B >= 1.1).\n\n        For successful replacement, ``provider`` must meet all the requirements\n        which ``other`` fulfills.\n\n        :param provider: The provider we are trying to replace with.\n        :param other: The provider we're trying to replace.\n        :param problems: If False is returned, this will contain what\n                         problems prevented replacement. This is currently\n                         a tuple of the literal string 'cantreplace',\n                         ``provider``, ``other``  and the set of requirements\n                         that ``provider`` couldn't fulfill.\n        :return: True if we can replace ``other`` with ``provider``, else\n                 False.\n        " #NEWLINE# rlist = self . reqts [ other ] #NEWLINE# unmatched = set ( ) #NEWLINE# for s in rlist : #NEWLINE# #INDENT# matcher = self . get_matcher ( s ) #NEWLINE# if ( not matcher . match ( provider . version ) ) : #NEWLINE# #INDENT# unmatched . add ( s ) #NEWLINE# #UNINDENT# #UNINDENT# if unmatched : #NEWLINE# #INDENT# problems . add ( ( 'cantreplace' , provider , other , frozenset ( unmatched ) ) ) #NEWLINE# result = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . remove_distribution ( other ) #NEWLINE# del self . reqts [ other ] #NEWLINE# for s in rlist : #NEWLINE# #INDENT# self . reqts . setdefault ( provider , set ( ) ) . add ( s ) #NEWLINE# #UNINDENT# self . add_distribution ( provider ) #NEWLINE# result = True #NEWLINE# #UNINDENT# return result