def generate_fake_facility_groups(names=('Class 4E', 'Class 5B'), facilities=None):
 if (not facilities):
  facilities = generate_fake_facilities()
 facility_groups = []
 for facility in facilities:
  for name in names:
   found_facility_groups = FacilityGroup.objects.filter(facility=facility, name=name)
   if found_facility_groups:
    facility_group = found_facility_groups[0]
    logging.info(("Retrieved facility group '%s'" % name))
   else:
    facility_group = FacilityGroup(facility=facility, name=name)
    facility_group.save()
    logging.info(("Created facility group '%s'" % name))
   facility_groups.append(facility_group)
 return (facility_groups, facilities)

def generate_fake_facility_groups ( names = ( 'Class 4E' , 'Class 5B' ) , facilities = None ) : if ( not facilities ) : facilities = generate_fake_facilities ( ) facility_groups = [ ] for facility in facilities : for name in names : found_facility_groups = FacilityGroup . objects . filter ( facility = facility , name = name ) if found_facility_groups : facility_group = found_facility_groups [ 0 ] logging . info ( ( "Retrieved facility group '%s'" % name ) ) else : facility_group = FacilityGroup ( facility = facility , name = name ) facility_group . save ( ) logging . info ( ( "Created facility group '%s'" % name ) ) facility_groups . append ( facility_group ) return ( facility_groups , facilities )
add the given fake facility groups to the given fake facilities .