def get_unique_databases_and_mirrors():
 mirrored_aliases = {}
 test_databases = {}
 dependencies = {}
 default_sig = connections[DEFAULT_DB_ALIAS].creation.test_db_signature()
 for alias in connections:
  connection = connections[alias]
  test_settings = connection.settings_dict['TEST']
  if test_settings['MIRROR']:
   mirrored_aliases[alias] = test_settings['MIRROR']
  else:
   item = test_databases.setdefault(connection.creation.test_db_signature(), (connection.settings_dict['NAME'], set()))
   item[1].add(alias)
   if ('DEPENDENCIES' in test_settings):
    dependencies[alias] = test_settings['DEPENDENCIES']
   elif ((alias != DEFAULT_DB_ALIAS) and (connection.creation.test_db_signature() != default_sig)):
    dependencies[alias] = test_settings.get('DEPENDENCIES', [DEFAULT_DB_ALIAS])
 test_databases = dependency_ordered(test_databases.items(), dependencies)
 test_databases = collections.OrderedDict(test_databases)
 return (test_databases, mirrored_aliases)

def get_unique_databases_and_mirrors ( ) : mirrored_aliases = { } test_databases = { } dependencies = { } default_sig = connections [ DEFAULT_DB_ALIAS ] . creation . test_db_signature ( ) for alias in connections : connection = connections [ alias ] test_settings = connection . settings_dict [ 'TEST' ] if test_settings [ 'MIRROR' ] : mirrored_aliases [ alias ] = test_settings [ 'MIRROR' ] else : item = test_databases . setdefault ( connection . creation . test_db_signature ( ) , ( connection . settings_dict [ 'NAME' ] , set ( ) ) ) item [ 1 ] . add ( alias ) if ( 'DEPENDENCIES' in test_settings ) : dependencies [ alias ] = test_settings [ 'DEPENDENCIES' ] elif ( ( alias != DEFAULT_DB_ALIAS ) and ( connection . creation . test_db_signature ( ) != default_sig ) ) : dependencies [ alias ] = test_settings . get ( 'DEPENDENCIES' , [ DEFAULT_DB_ALIAS ] ) test_databases = dependency_ordered ( test_databases . items ( ) , dependencies ) test_databases = collections . OrderedDict ( test_databases ) return ( test_databases , mirrored_aliases )
figure out which databases actually need to be created .