def get_zone_by_name(conn, module, zone_name, want_private, zone_id, want_vpc_id):
 for zone in conn.get_zones():
  private_zone = module.boolean(zone.config.get('PrivateZone', False))
  if ((private_zone == want_private) and (((zone.name == zone_name) and (zone_id == None)) or (zone.id.replace('/hostedzone/', '') == zone_id))):
   if want_vpc_id:
    zone_details = conn.get_hosted_zone(zone.id)['GetHostedZoneResponse']
    if isinstance(zone_details['VPCs'], dict):
     if (zone_details['VPCs']['VPC']['VPCId'] == want_vpc_id):
      return zone
    elif (want_vpc_id in [v['VPCId'] for v in zone_details['VPCs']]):
     return zone
   else:
    return zone
 return None

def get_zone_by_name ( conn , module , zone_name , want_private , zone_id , want_vpc_id ) : for zone in conn . get_zones ( ) : private_zone = module . boolean ( zone . config . get ( 'PrivateZone' , False ) ) if ( ( private_zone == want_private ) and ( ( ( zone . name == zone_name ) and ( zone_id == None ) ) or ( zone . id . replace ( '/hostedzone/' , '' ) == zone_id ) ) ) : if want_vpc_id : zone_details = conn . get_hosted_zone ( zone . id ) [ 'GetHostedZoneResponse' ] if isinstance ( zone_details [ 'VPCs' ] , dict ) : if ( zone_details [ 'VPCs' ] [ 'VPC' ] [ 'VPCId' ] == want_vpc_id ) : return zone elif ( want_vpc_id in [ v [ 'VPCId' ] for v in zone_details [ 'VPCs' ] ] ) : return zone else : return zone return None
finds a zone by name or zone_id .