

def build_schedule(self):
    created_items = []
    reader = csv.DictReader(self.cleaned_data.get('filename'))
    data = [dict(((k.strip(), v.strip()) for (k, v) in x.items())) for x in reader]
    created_items.extend(self._build_rooms(data))
    created_items.extend(self._build_days(data))
    for row in data:
        room = Room.objects.get(schedule=self.schedule, name=row[self.ROOM_KEY])
        date = datetime.strptime(row[self.DATE_KEY], '%m/%d/%Y')
        day = Day.objects.get(schedule=self.schedule, date=date)
        (start, end) = self._get_start_end_times(row)
        (slot_kind, created) = SlotKind.objects.get_or_create(label=row[self.KIND], schedule=self.schedule)
        if created:
            created_items.append(slot_kind)
        if (row[self.KIND] == 'plenary'):
            (slot, created) = Slot.objects.get_or_create(kind=slot_kind, day=day, start=start, end=end)
            if created:
                created_items.append(slot)
        else:
            slot = Slot.objects.create(kind=x, day=day, start=start, end=end)
            created_items.append(slot)
        try:
            with transaction.atomic():
                SlotRoom.objects.create(slot=slot, room=room)
        except IntegrityError:
            for x in created_items:
                x.delete()
            return (messages.ERROR, 'An overlap occurred; the import was cancelled.')
    return (messages.SUCCESS, 'Your schedule has been imported.')

dataset/ETHPy150Open pinax/symposion/symposion/schedule/forms.py ScheduleSectionForm.build_schedule/VarMisuse@285/339 `slot_kind`->`x`