def __instantiate_from_dict(self, data):
        """
        Will populate the model from a dictionary passed as a constructor.
        """

        if type(data) == dict:
            for key in data.keys():
                if self.has_key(key):
                    val = data[key]
                    if isinstance(val, dict):
                        model_instance = self.__class__.__dict__[key].to(val)
                        self.__field_map[key].value = model_instance
                        self.__dict__[key] = self.__field_map[key].value
                        self[key] = self.__field_map[key].value

                    else:
                        self.__field_map[key].value = data[key]
                        self.__dict__[key] = self.__field_map[key].value
                        self[key] = self.__field_map[key].value


                else:
                    logging.warning("Ignoring '%s' from input, couldn't find matching model Field entry" % (key) )

        else:
            raise ValueError('Input data to model must be a dictionary')
dataset/ETHPy150Open lonelycode/Mojo/Mojo/ObjectMapper/ModelPrototype.py/Model.__instantiate_from_dict/original