#NEWLINE# def cmp_by_priority_prefer_installed( self , pool , installed_map , a , b , required_package = None , ignore_replace = False ) : #NEWLINE# #INDENT# '\n        Comparison function that gives priority to installed packages first, and\n        then across repository priorities.\n        ' #NEWLINE# if ( id ( a . repository ) == id ( b . repository ) ) : #NEWLINE# #INDENT# if ( not ignore_replace ) : #NEWLINE# #INDENT# if self . _replaces ( a , b ) : #NEWLINE# #INDENT# return 1 #NEWLINE# #UNINDENT# if self . _replaces ( b , a ) : #NEWLINE# #INDENT# return ( - 1 ) #NEWLINE# #UNINDENT# #UNINDENT# if ( required_package is not None ) : #NEWLINE# #INDENT# raise NotImplementedError ( 'required_package handling not implemented yet' ) #NEWLINE# #UNINDENT# if ( a . id > b . id ) : #NEWLINE# #INDENT# return 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( a . id < ignore_replace . id ) : #NEWLINE# #INDENT# return ( - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return 0 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( a . id in installed_map ) : #NEWLINE# #INDENT# return ( - 1 ) #NEWLINE# #UNINDENT# if ( b . id in installed_map ) : #NEWLINE# #INDENT# return 1 #NEWLINE# #UNINDENT# if ( self . _priority ( pool , a ) > self . _priority ( pool , b ) ) : #NEWLINE# #INDENT# return ( - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return 1