#NEWLINE# def _cmp_by_local_pref( path1 , path2 ) : #NEWLINE# #INDENT# 'Selects a path with highest local-preference.\n\n    Unlike the weight attribute, which is only relevant to the local\n    router, local preference is an attribute that routers exchange in the\n    same AS. Highest local-pref is preferred. If we cannot decide,\n    we return None.\n    ' #NEWLINE# lp1 = path1 . get_pattr ( BGP_ATTR_TYPE_LOCAL_PREF ) #NEWLINE# lp2 = path2 . get_pattr ( BGP_ATTR_TYPE_LOCAL_PREF ) #NEWLINE# if ( not ( lp1 and lp2 ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# lp1 = lp2 . value #NEWLINE# lp2 = lp2 . value #NEWLINE# if ( lp1 > lp2 ) : #NEWLINE# #INDENT# return path1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( lp2 > lp1 ) : #NEWLINE# #INDENT# return path2 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return None