# Path: src/data_migrator/models/manager.py
# class SimpleManager(BaseManager):
#     """
#     The default manager to handle models, all standard logic and generates one
#     object per row
#     """
#     def transform(self, row, previous, model):
#         '''specific transform implementation, instantiates one object
#         from a row
#         '''
#         res = [model().scan(row)]
#         return res


from six import with_metaclass
from data_migrator.exceptions import DataException
from .manager import SimpleManager
from .fields import BaseField, HiddenField
from .options import Options
    def __new__(mcs, name, bases, attrs):
        super_new = super(ModelBase, mcs).__new__

        # Also ensure initialization is only performed for subclasses of Model
        # (excluding Model class itself).
        parents = [b for b in bases if isinstance(b, ModelBase)]
        if not parents:
            return super_new(mcs, name, bases, attrs)

        module = attrs.pop('__module__')
        new_class = super_new(mcs, name, bases, {'__module__': module})

        # Check if we have a meta class
        attr_meta = attrs.pop('Meta', None)
        if not attr_meta:
            meta = getattr(new_class, 'Meta', None)
        else:
            meta = attr_meta

        # declare the fields
        fields = {}
        for n, d in attrs.items():
            if isinstance(d, BaseField):
                fields[n] = d
                setattr(d, 'name', getattr(d, 'name') or n)

        # now prepare the meta class/options
        setattr(new_class, '_meta', Options(new_class, meta, fields=fields))

        # instantiate the manager

# Path: src/data_migrator/models/manager.py
# class SimpleManager(BaseManager):
#     """
#     The default manager to handle models, all standard logic and generates one
#     object per row
#     """
#     def transform(self, row, previous, model):
#         '''specific transform implementation, instantiates one object
#         from a row
#         '''
#         res = [model().scan(row)]
#         return res


# Path: src/data_migrator/models/base.py
from six import with_metaclass
from data_migrator.exceptions import DataException
from .manager import SimpleManager
from .fields import BaseField, HiddenField
from .options import Options

    def __new__(mcs, name, bases, attrs):
        super_new = super(ModelBase, mcs).__new__

        # Also ensure initialization is only performed for subclasses of Model
        # (excluding Model class itself).
        parents = [b for b in bases if isinstance(b, ModelBase)]
        if not parents:
            return super_new(mcs, name, bases, attrs)

        module = attrs.pop('__module__')
        new_class = super_new(mcs, name, bases, {'__module__': module})

        # Check if we have a meta class
        attr_meta = attrs.pop('Meta', None)
        if not attr_meta:
            meta = getattr(new_class, 'Meta', None)
        else:
            meta = attr_meta

        # declare the fields
        fields = {}
        for n, d in attrs.items():
            if isinstance(d, BaseField):
                fields[n] = d
                setattr(d, 'name', getattr(d, 'name') or n)

        # now prepare the meta class/options
        setattr(new_class, '_meta', Options(new_class, meta, fields=fields))

        # instantiate the manager

        _manager = getattr(meta, 'manager', SimpleManager)()