Create a new instance from dict

        :param data: A JSON dict
498813
def from_dict(data):
        
        data = deepcopy(data)

        created_at = data.get('created_at', None)
        if created_at is not None:
            data['created_at'] = dateutil.parser.parse(created_at)

        return Image(**data)
871303
def json_data(self, instance, default=None):
        
        value = self.get(instance)

        out = []
        for rel in value:
            if rel.isBroken():
                logger.warn("Skipping broken relation {}".format(repr(rel)))
                continue
            obj = rel.to_object
            out.append(api.get_url_info(obj))
        return out
1116748
def from_json(self, json, models=None):
        ''' 
        '''
        if json is None:
            return None
        elif not isinstance(json, dict):
            raise DeserializationError("%s expected a dict or None, got %s" % (self, json))
        new_data = {}
        for key, value in json.items():
            key = self.keys_type.from_json(key, models)
            if isinstance(value, dict) and '__ndarray__' in value:
                new_data[key] = decode_base64_dict(value)
            elif isinstance(value, list) and any(isinstance(el, dict) and '__ndarray__' in el for el in value):
                new_list = []
                for el in value:
                    if isinstance(el, dict) and '__ndarray__' in el:
                        el = decode_base64_dict(el)
                    elif isinstance(el, list):
                        el = self.values_type.from_json(el)
                    new_list.append(el)
                new_data[key] = new_list
            else:
                new_data[key] = self.values_type.from_json(value, models)
        return new_data
910895
def create(self, data={}, **kwargs):
        "
        url = self.base_url
        return self.post_url(url, data, **kwargs)
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"])
883945
def new(cls, data=None):
		
		obj = cls()
		if data is not None:
			obj.update(data)
		return obj
468489
def from_json(json_data):
        
        # If we have a string, then decode it, otherwise assume it's already decoded
        if isinstance(json_data, str):
            data = json.loads(json_data)
        else:
            data = json_data
        oauth_dict = {
                      'client_id':data.get('oauth',{}).get('client_id',None),
                      'client_secret':data.get('oauth',{}).get('client_secret',None),
                      'redirect_url':data.get('oauth',{}).get('redirect_url',None),
                      }
        client = Client(api_key=data.get('api_key',None),
                        api_url=data.get('api_url',None),
                        oauth=oauth_dict,
                        use_cache=data.get('use_cache',None),
                        cache_dir=data.get('cache_dir',None),
                        update_cache=data.get('update_cache',None),
                        verifySSL=data.get('oauth',{}).get('verifySSL',None)
                        )
        client.cache = Cache.from_json(data.get('cache',None))
        client.oauth = OAuth2.from_json(data.get('oauth',None))
        return client
718591
def from_json(stream, cls=None, object_pairs_hook=OrderedDict, **extras):
    
    stream = stream.read() if hasattr(stream, 'read') else stream
    json_dict = json.loads(stream, object_pairs_hook=object_pairs_hook)
    if extras:
        json_dict.update(extras)  # pragma: no cover
    return to_model(cls, json_dict) if cls else json_dict
1306286
def FromData(cls, stream, json_data, http=None, auto_transfer=None,
                 **kwds):
        """"""
        info = json.loads(json_data)
        missing_keys = cls._REQUIRED_SERIALIZATION_KEYS - set(info.keys())
        if missing_keys:
            raise exceptions.InvalidDataError(
                'Invalid serialization data, missing keys: %s' % (
                    ', '.join(missing_keys)))
        download = cls.FromStream(stream, **kwds)
        if auto_transfer is not None:
            download.auto_transfer = auto_transfer
        else:
            download.auto_transfer = info['auto_transfer']
        setattr(download, '_Download__progress', info['progress'])
        setattr(download, '_Download__total_size', info['total_size'])
        download._Initialize(  # pylint: disable=protected-access
            http, info['url'])
        return download
897866
def perform_create(self, data):
        

        instance = self.model(**data)
        self.request.dbsession.add(instance)
        self.request.dbsession.flush()
        return instance
764797
def _data_to_json(data):
        
        if type(data) not in [str, unicode]:
            data = json.dumps(data)
        return data
151748
def _fromJSON(cls, jsonobject):
        
        newInstance = cls(jsonobject[0], jsonobject[1])
        for arrayType, jsonEntry in viewitems(jsonobject[2]):
            arrayEntry = {'dataProcessingRef': jsonEntry['dataProcessingRef'],
                          'params': [tuple(_) for _ in jsonEntry['params']]
                          }
            newInstance.arrayInfo[arrayType] = arrayEntry

        return newInstance
1007384
def from_json(cls, data):
        
        optional_keys = ('city', 'state', 'country', 'latitude', 'longitude',
                         'time_zone', 'elevation', 'station_id', 'source')
        for key in optional_keys:
            if key not in data:
                data[key] = None

        return cls(data['city'], data['state'], data['country'], data['latitude'],
                   data['longitude'], data['time_zone'], data['elevation'],
                   data['station_id'], data['source'])
826088
def NewFromJSON(data):
        
        return Comment(
            body=data.get('body', None),
            posted_at=data.get('posted_at', None),
            user=User.NewFromJSON(data.get('user', None))
        )
939631
def from_json(cls, data):
        
        user = cls()

        user.user_id = data['userId']
        user.username = data['username']
        user.auth_system = data['authSystem']
        user.roles = data['roles']

        return user
1217782
def import_from_dicts(data, samples=None, *args, **kwargs):
    

    data = iter(data)

    cached_rows, headers = [], []
    for index, row in enumerate(data, start=1):
        cached_rows.append(row)

        for key in row.keys():
            if key not in headers:
                headers.append(key)

        if samples and index == samples:
            break

    data_rows = (
        [row.get(header, None) for header in headers]
        for row in chain(cached_rows, data)
    )

    kwargs["samples"] = samples
    meta = {"imported_from": "dicts"}
    return create_table(chain([headers], data_rows), meta=meta, *args, **kwargs)
228876
def create(self, data):
				
		q = self.history.insert_one(data).inserted_id
		logging.debug(self.history.find_one({"_id":q}))