def _cmp_by_asn(local_asn, path1, path2):
 def get_path_source_asn(path):
  asn = None
  if (path.source is None):
   asn = local_asn
  else:
   asn = path.source.remote_as
  return asn
 p1_asn = get_path_source_asn(path1)
 p2_asn = get_path_source_asn(path2)
 if ((p1_asn == local_asn) and (p2_asn != local_asn)):
  return path2
 if ((p2_asn == local_asn) and (p1_asn != local_asn)):
  return path1
 return None

def _cmp_by_asn ( local_asn , path1 , path2 ) : def get_path_source_asn ( path ) : asn = None if ( path . source is None ) : asn = local_asn else : asn = path . source . remote_as return asn p1_asn = get_path_source_asn ( path1 ) p2_asn = get_path_source_asn ( path2 ) if ( ( p1_asn == local_asn ) and ( p2_asn != local_asn ) ) : return path2 if ( ( p2_asn == local_asn ) and ( p1_asn != local_asn ) ) : return path1 return None
select the path based on source peer .