Creates a model instance with the given data.

        Args:
            data: Model data returned from DB.
            key: Object key
        Returns:
            pyoko.Model object.
501395
def _make_model(self, data, key=None):
        
        if data['deleted'] and not self.adapter.want_deleted:
            raise ObjectDoesNotExist('Deleted object returned')
        model = self._model_class(self._current_context,
                                  _pass_perm_checks=self._pass_perm_checks)

        model.setattr('key', ub_to_str(key) if key else ub_to_str(data.get('key')))
        model = model.set_data(data, from_db=True)
        model._initial_data = model.clean_value()
        return model
286152
async def create(self, model_, **data):
        
        inst = model_(**data)
        query = model_.insert(**dict(inst.__data__))

        pk = await self.execute(query)
        if inst._pk is None:
            inst._pk = pk
        return inst
302082
def from_dict(cls, database, key, data, clear=False):
        
        zset = cls(database, key)
        if clear:
            zset.clear()
        zset.add(data)
        return zset
1315057
def create(cls, *args, **kwargs) -> 'Entity':
        
        logger.debug(
            f'Creating new `{cls.__name__}` object using data {kwargs}')

        model_cls = repo_factory.get_model(cls)
        repository = repo_factory.get_repository(cls)

        try:
            # Build the entity from the input arguments
            # Raises validation errors, if any, at this point
            entity = cls(*args, **kwargs)

            # Do unique checks, create this object and return it
            entity._validate_unique()

            # Perform Pre-Save Actions
            entity.pre_save()

            # Build the model object and create it
            model_obj = repository.create(model_cls.from_entity(entity))

            # Update the auto fields of the entity
            for field_name, field_obj in entity.meta_.declared_fields.items():
                if isinstance(field_obj, Auto):
                    if isinstance(model_obj, dict):
                        field_val = model_obj[field_name]
                    else:
                        field_val = getattr(model_obj, field_name)
                    setattr(entity, field_name, field_val)

            # Set Entity status to saved
            entity.state_.mark_saved()

            # Perform Post-Save Actions
            entity.post_save()

            return entity
        except ValidationError:
            # FIXME Log Exception
            raise
228876
def create(self, data):
				
		q = self.history.insert_one(data).inserted_id
		logging.debug(self.history.find_one({"_id":q}))
938659
def instantiate_from_data(self, object_data):
        
        if isinstance(object_data, dict) and 'name' in object_data:
            name = object_data['name']
            module = importlib.import_module(name)
            return self.resolve_and_call(module.create, extra_env=object_data)
        if isinstance(object_data, dict) and 'factory' in object_data:
            factory = object_data['factory']
            module = importlib.import_module(factory)
            params = self.resolve_parameters(module.create, extra_env=object_data)
            return GenericFactory(module.create, params)
        elif isinstance(object_data, dict):
            return {k: self.instantiate_from_data(v) for k, v in object_data.items()}
        elif isinstance(object_data, list):
            return [self.instantiate_from_data(x) for x in object_data]
        elif isinstance(object_data, Variable):
            return object_data.resolve(self.parameters)
        else:
            return object_data
1281951
def create_from_name_and_dictionary(self, name, datas):
        
        category = ObjectCategory(name)
        self.set_common_datas(category, name, datas)

        if "order" in datas:
            category.order = int(datas["order"])

        return category
1360648
def initial_populate(self, data):
        
        if self.config.parsed:
            return False
        # Otherwise, create a new ConfigKey.
        self.config.load_from_dict(data)
        return True
443502
def from_data(data):
    
    if len(data) == 0:  # pragma: no cover
        return None
    else:
        ptable = PrettyTable()
        ptable.field_names = data[0].keys()
        for row in data:
            ptable.add_row(row)
        return ptable
1054593
def initialize_class(data, *args, **kwargs):
    
    if isinstance(data, dict):
        import_path = data.get('import_path')
        data.update(kwargs)
        Class = import_module(import_path)

        return Class(*args, **data)
    else:
        Class = import_module(data)

        return Class(*args, **kwargs)
594625
def create(self, data, fields=[], models={}):
        '''
        
        '''
        if not fields: fields = self.fields
        if not models and hasattr(self, 'models'): models = self.models
        for field in fields:
            setattr(self,field,None)
        if not data: return None
        for k, v in data.iteritems():
            if type(v) in (str, unicode):
                v = v.strip()
            if models and k in models:
                if type(v) == dict:
                    lists = []
                    for k2, v2 in v.iteritems():
                        if type(v2) == list:
                            for d in v2:
                                model = models[k]()
                                lists.append(model.create(d))
                    if not lists:
                        model = models[k]()
                        v = model.create(v)
                    else:
                        v = lists
                else:
                    model = models[k]()
                    v = model.create(v)
            setattr(self,k,v)
        return self
1187236
def create(self, data, *args, **kwargs):
        
        # if module of the function is diferent from the module of the object
        # that means create is not implemented in child class
        if self.create.__func__.__module__ != self.__module__:
            raise Exception("Child method not implemented")

        self._MambuStruct__method  = "POST"
        self._MambuStruct__data    = data
        self.connect(*args, **kwargs)
        self._MambuStruct__method  = "GET"
        self._MambuStruct__data    = None
956093
def load(cls, data):
        
        if len(data) == 1:
            for key, value in data.items():
                if "__classname__" not in value:  # pragma: no cover
                    raise ValueError
                name = key
                bases = (Constant,)
                attrs = dict()
                for k, v in value.items():
                    if isinstance(v, dict):
                        if "__classname__" in v:
                            attrs[k] = cls.load({k: v})
                        else:
                            attrs[k] = v
                    else:
                        attrs[k] = v
            return type(name, bases, attrs)
        else:  # pragma: no cover
            raise ValueError
68044
def _load_data(self, data, from_db=False):
        
        self._data = data[:]
        self.setattrs(
            values=[],
            node_stack=[],
            node_dict={},
        )
        self._from_db = from_db
976899
protected function createModel($data) {
		$modelClass = $this->getModel();
			
		$model = $modelClass::factory($data);

		if ($this->hasDatagate()) {
			$model->setDatagate($this->getDatagate());
		}
		
		if ($this->hasLocator()) {
			$model->setLocator($this->getLocator());
		}
		
		return $model;
	}
1364475
def create_data_and_metadata_from_data(self, data: numpy.ndarray, intensity_calibration: Calibration.Calibration=None, dimensional_calibrations: typing.List[Calibration.Calibration]=None, metadata: dict=None, timestamp: str=None) -> DataAndMetadata.DataAndMetadata:
        
        ...
159151
def from_dict(self, data):
        
        if "model" in data:
            model = data["model"]
            self.description = model["description"] if "description" in model else None
            self.package = model["package"] if "package" in model else None
            self.extends = model["extends"] if "extends" in model else []
            self.entity_name = model["entity_name"] if "entity_name" in model else None
            self.rest_name = model["rest_name"] if "rest_name" in model else None
            self.resource_name = model["resource_name"] if "resource_name" in model else None
            self.allows_get = model["get"] if "get" in model else False
            self.allows_create = model["create"] if "create" in model else False
            self.allows_update = model["update"] if "update" in model else False
            self.allows_delete = model["delete"] if "delete" in model else False
            self.is_root = model["root"] if "root" in model else False
            self.userlabel = model["userlabel"] if "userlabel" in model else None
            self.template = model["template"] if "template" in model else False
            self.allowed_job_commands = model["allowed_job_commands"] if "allowed_job_commands" in model else None

        if "attributes" in data:
            self.attributes = self._get_attributes(data["attributes"])

        if "children" in data:
            self.child_apis = self._get_apis(data["children"])