

def _iter_rows(self):
    model_meta = self.model_class._meta
    if self._validate_fields:
        valid_fields = (set(model_meta.fields.keys()) | set(model_meta.fields.values()))

        def validate_field(field):
            if (field not in valid_fields):
                raise KeyError(('"%s" is not a recognized field.' % field))
    defaults = model_meta._default_dict
    callables = model_meta._default_callables
    for row_dict in self._rows:
        field_row = defaults.copy()
        seen = set()
        for key in row_dict:
            if self._validate_fields:
                validate_field(key)
            if (key in model_meta.fields):
                field = model_meta.fields[key]
            else:
                field = key
            field_row[field] = row_dict[key]
            seen.add(field)
        if callables:
            for field in callables:
                if (field not in seen):
                    field_row[field] = callables[field]()
        (yield field_row)

dataset/ETHPy150Open coleifer/peewee/peewee.py InsertQuery._iter_rows/original