def lookup_connections(backend, identities):
 if isinstance(backend, string_types):
  (backend, _) = Backend.objects.get_or_create(name=backend)
 connections = []
 for identity in identities:
  (connection, _) = backend.connection_set.get_or_create(identity=identity)
  connections.append(connection)
 return connections

def lookup_connections ( backend , identities ) : if isinstance ( backend , string_types ) : ( backend , _ ) = Backend . objects . get_or_create ( name = backend ) connections = [ ] for identity in identities : ( connection , _ ) = backend . connection_set . get_or_create ( identity = identity ) connections . append ( connection ) return connections
find connections associated with backend and identities .