def _cmp_by_local_pref(path1, path2):
 lp1 = path1.get_pattr(BGP_ATTR_TYPE_LOCAL_PREF)
 lp2 = path2.get_pattr(BGP_ATTR_TYPE_LOCAL_PREF)
 if (not (lp1 and lp2)):
  return None
 lp1 = lp1.value
 lp2 = lp2.value
 if (lp1 > lp2):
  return path1
 elif (lp2 > lp1):
  return path2
 else:
  return None

def _cmp_by_local_pref ( path1 , path2 ) : lp1 = path1 . get_pattr ( BGP_ATTR_TYPE_LOCAL_PREF ) lp2 = path2 . get_pattr ( BGP_ATTR_TYPE_LOCAL_PREF ) if ( not ( lp1 and lp2 ) ) : return None lp1 = lp1 . value lp2 = lp2 . value if ( lp1 > lp2 ) : return path1 elif ( lp2 > lp1 ) : return path2 else : return None
selects a path with highest local-preference .