@classmethod
    def get_object(self, desc, value):
        klass = desc['klass']
        attr  = desc['attr']

        try:
            if desc['prefetch']:

                # build up relation cache
                if klass not in self.relation_cache:
                    self.buildup_relation_cache(klass, attr, value,
                                                desc['assign_by_id'])

                # get the instance out of relation cache
                inst = self.relation_cache[klass].get(value, None)
                if inst:
                    return inst

                raise ObjectDoesNotExist(
                    "%s matching query (%s=%s) does not exist in relation cache." % (
                        klass.__name__, attr, value))

            else:
                # get the related object out of the DB
                return klass.objects.get(**{ attr: value })

        except __HOLE__ as e:
            if desc['skip_missing']:
                return None
            else:
                raise
dataset/ETHPy150Open pboehm/django-data-migration/data_migration/migration.py/Migration.get_object