# Path: mtr/sync/lib/signals.py

# 
# Path: mtr/sync/lib/exceptions.py
# class ErrorChoicesMixin(object):
#     IMPORT_DATA = 0
#     UNDEFINED = 1
# 
#     STEP_CHOICES = (
#         (IMPORT_DATA, _('import data')),
#         (UNDEFINED, _('unexpected error'))
#     )
# 
# Path: mtr/sync/settings.py
# SETTINGS = getattr_with_prefix('SYNC', 'SETTINGS', {
#     'path': get_buffer_file_path,
#     'default_processor': 'XlsxProcessor',
#     'actions': ['mtr.sync.lib.actions'],
#     'converters': ['mtr.sync.lib.converters'],
#     'processors': [
#         'mtr.sync.lib.processors.xlsx',
#         'mtr.sync.lib.processors.xls',
#         'mtr.sync.lib.processors.ods',
#         'mtr.sync.lib.processors.csv',
#     ],
#     'broker': 'rq',
#     'include': {
#         'api': False,
#         'admin': True,
#     }
# })


import os
import traceback
from django.utils.six.moves import range
from django.utils import timezone
from django.db import transaction, Error
from django.core.exceptions import ValidationError
from .signals import export_started, export_completed, \
    import_started, import_completed, error_raised
from .exceptions import ErrorChoicesMixin
from ..settings import SETTINGS

        attrs = related_attrs.get(key_model, {})
        attrs[key_attr] = value
        related_attrs[key_model] = attrs

        return related_attrs

    def prepare_attrs(self, _model):
        model_attrs = {}
        related_attrs = {}

        for key in _model.keys():
            if '|_fk_|' in key:
                related_attrs = self._prepare_fk_attrs(
                    related_attrs, key, _model)
            elif '|_m_|' in key:
                related_attrs = self._prepare_mtm_attrs(
                    related_attrs, key, _model)
            else:
                model_attrs[key] = _model[key]

        return model_attrs, related_attrs

    def import_data(self, model, path=None):
        """Import data to model and return errors if exists"""

        if self.settings.buffer_file:
            path = self.settings.buffer_file.path

        # send signal to create report

# Path: mtr/sync/lib/signals.py

# 
# Path: mtr/sync/lib/exceptions.py
# class ErrorChoicesMixin(object):
#     IMPORT_DATA = 0
#     UNDEFINED = 1
# 
#     STEP_CHOICES = (
#         (IMPORT_DATA, _('import data')),
#         (UNDEFINED, _('unexpected error'))
#     )
# 
# Path: mtr/sync/settings.py
# SETTINGS = getattr_with_prefix('SYNC', 'SETTINGS', {
#     'path': get_buffer_file_path,
#     'default_processor': 'XlsxProcessor',
#     'actions': ['mtr.sync.lib.actions'],
#     'converters': ['mtr.sync.lib.converters'],
#     'processors': [
#         'mtr.sync.lib.processors.xlsx',
#         'mtr.sync.lib.processors.xls',
#         'mtr.sync.lib.processors.ods',
#         'mtr.sync.lib.processors.csv',
#     ],
#     'broker': 'rq',
#     'include': {
#         'api': False,
#         'admin': True,
#     }
# })


# Path: mtr/sync/lib/processor.py
import os
import traceback
from django.utils.six.moves import range
from django.utils import timezone
from django.db import transaction, Error
from django.core.exceptions import ValidationError
from .signals import export_started, export_completed, \
    import_started, import_completed, error_raised
from .exceptions import ErrorChoicesMixin
from ..settings import SETTINGS


        attrs = related_attrs.get(key_model, {})
        attrs[key_attr] = value
        related_attrs[key_model] = attrs

        return related_attrs

    def prepare_attrs(self, _model):
        model_attrs = {}
        related_attrs = {}

        for key in _model.keys():
            if '|_fk_|' in key:
                related_attrs = self._prepare_fk_attrs(
                    related_attrs, key, _model)
            elif '|_m_|' in key:
                related_attrs = self._prepare_mtm_attrs(
                    related_attrs, key, _model)
            else:
                model_attrs[key] = _model[key]

        return model_attrs, related_attrs

    def import_data(self, model, path=None):
        """Import data to model and return errors if exists"""

        if self.settings.buffer_file:
            path = self.settings.buffer_file.path

        # send signal to create report

        for response in import_started.send(self, path=path):