Sets the attributes dictionary from a JSON string.
514716
def setAttributesJson(self, attributesJson):
        
        try:
            self._attributes = json.loads(attributesJson)
        except:
            raise exceptions.InvalidJsonException(attributesJson)
        return self
643198
def load(self, value):
        """"""

        if not isinstance(value, str):
            raise TypeError('Expected JSON string')

        _value = json.loads(value)
        self._validate_word(value=_value)
        self.word = _value
538548
def set_attrs_from_response(response)
      unless response.body.nil? || (response.body.length < 2)
        json = self.class.parse_json(response.body)
        set_attrs(json)
      end
    end
787023
def _initialize_attributes(self, data):
    """"""
    attrs = dict(self.attrs)

    if self.primary_key_name is None:
      pass
    elif isinstance(self.primary_key_name, str):
      if self.primary_key_name not in attrs:
        attrs[self.primary_key_name] = None
    else:
      for pkey in self.primary_key_name:
        if pkey not in attrs:
          attrs[pkey] = None

    if self.timestamps:
      for ts_name in self.timestamps:
        if ts_name is not None and ts_name not in attrs:
          attrs[ts_name] = None

    for attr_name in attrs:
      setattr(self, attr_name, get_value(data, attr_name, attrs[attr_name]))
988600
def loadJson(self, data):
        """"""
        if not isinstance(data, dict):
            data = json.loads(data)
        self.__dict__.update(data)
        self.inflate() # restore objects from str values
        #if self.ports:  self._gotPorts = True
        return self
395523
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'location' in _dict:
            args['location'] = Location._from_dict(_dict.get('location'))
        if 'text' in _dict:
            args['text'] = _dict.get('text')
        if 'types' in _dict:
            args['types'] = [
                TypeLabel._from_dict(x) for x in (_dict.get('types'))
            ]
        if 'categories' in _dict:
            args['categories'] = [
                Category._from_dict(x) for x in (_dict.get('categories'))
            ]
        if 'attributes' in _dict:
            args['attributes'] = [
                Attribute._from_dict(x) for x in (_dict.get('attributes'))
            ]
        return cls(**args)
1145348
def set_from_dict(self, data, source=None):
        
        if source:
            self._source = source

        if not data:
            return

        for key, value in data.items():
            key = key.replace("-", "_")
            if not hasattr(self, key):
                LOG.debug("%s is not an attribute of %s", key, self.__class__.__name__)
                continue

            attr = getattr(self, key)
            if attr is not None and not same_type(value, attr):
                source = getattr(self, "_source", None)
                origin = " in %s" % source if source else ""
                LOG.debug("Wrong type '%s' for %s.%s%s, expecting '%s'", type_name(value), type_name(self), key, origin, type_name(attr))
                continue

            setattr(self, key, value)
784
def setattrdeep(obj, attr, val):
    ''
    attrs = attr.split('.')

    for a in attrs[:-1]:
        obj = getattr(obj, a)
    setattr(obj, attrs[-1], val)
702555
def set_parse_attributes(self, string, location, tokens):
        ""
        self.string = string
        self.location = location
        self.tokens = tokens
        return self
279446
def attrs(
    maybe_cls=None, type=None, context=None, translate=None, **attrs_kwargs
):
    """"""
    if isinstance(type, (list, tuple, set)):
        types = list(type)
    else:
        types = [type] if type is not None else []
    context = context or {}
    translate = translate or {}

    def wrap(cls):
        """Decorate an attr enabled class."""
        jsonld_cls = attr.s(cls, **attrs_kwargs)

        if not issubclass(jsonld_cls, JSONLDMixin):
            jsonld_cls = attr.s(
                make_type(cls.__name__, (jsonld_cls, JSONLDMixin), {}),
                **attrs_kwargs
            )

        # Merge types
        for subcls in jsonld_cls.mro():
            subtype = getattr(subcls, '_jsonld_type', None)
            if subtype:
                if isinstance(subtype, (tuple, list)):
                    types.extend(subtype)
                else:
                    types.append(subtype)

            for key, value in getattr(subcls, '_jsonld_context', {}).items():
                if key in context and context[key] != value:
                    raise TypeError()
                context.setdefault(key, value)

        for a in attr.fields(jsonld_cls):
            key = a.name
            ctx = a.metadata.get(KEY)
            if ctx is None:
                continue

            if ':' in ctx:
                prefix, _ = ctx.split(':', 1)
                if prefix in context:
                    context[key] = ctx
                    continue

            if isinstance(ctx, dict) or ctx not in context:
                context[key] = ctx

            if KEY_CLS in a.metadata:
                merge_ctx = a.metadata[KEY_CLS]._jsonld_context
                for ctx_key, ctx_value in merge_ctx.items():
                    context.setdefault(ctx_key, ctx_value)
                    if context[ctx_key] != ctx_value:
                        raise TypeError(
                            'Can not merge {0} and {1} because of {2}'.format(
                                jsonld_cls, a.metadata[KEY_CLS], ctx_key
                            )
                        )

        jsonld_cls.__module__ = cls.__module__
        jsonld_cls._jsonld_type = types[0] if len(types) == 1 else list(
            sorted(set(types))
        )
        jsonld_cls._jsonld_context = context
        jsonld_cls._jsonld_translate = translate
        jsonld_cls._jsonld_fields = {
            a.name
            for a in attr.fields(jsonld_cls) if KEY in a.metadata
        }

        context_doc = '\n'.join(
            '   ' + line for line in json.dumps(context, indent=2).split('\n')
        )
        jsonld_cls.__doc__ = DOC_TPL.format(
            cls=cls,
            type=json.dumps(jsonld_cls._jsonld_type),
            context=context_doc,
        )

        # Register class for given JSON-LD @type
        try:
            type_ = ld.expand({
                '@type': jsonld_cls._jsonld_type,
                '@context': context
            })[0]['@type']
            if isinstance(type_, list):
                type_ = tuple(sorted(type_))
        except Exception:
            # FIXME make sure all classes have @id defined
            return jsonld_cls

        if type_ in jsonld_cls.__type_registry__:
            raise TypeError(
                'Type {0!r} is already registered for class {1!r}.'.format(
                    jsonld_cls._jsonld_type,
                    jsonld_cls.__type_registry__[jsonld_cls._jsonld_type],
                )
            )
        jsonld_cls.__type_registry__[type_] = jsonld_cls
        return jsonld_cls

    if maybe_cls is None:
        return wrap
    return wrap(maybe_cls)
480629
def set_attributes(self, **attributes_dict):
        
        for attr_name, attr_value in attributes_dict.items():
            self.set_attr(attr_name, attr_value)
        return self
184269
def set_json(self, config_json):
        """"""

        if self.configuration_dict is not None:
            raise RuntimeError("Can only set configuration once", self.configuration_dict)

        schema = fetch_config('ConfigurationSchema.json')
        validictory.validate(config_json, schema)

        config_json['name'] = self.name
        config_json['run_number'] = self.run
        config_json['src_dir'] = get_source_dir()
        config_json['data_dir'] = get_data_dir()
        config_json['log_dir'] = get_log_dir()

        self.configuration_dict = config_json
705754
def _initialize_from_dict(self, data):
        
        self._json = data
        self._validate()

        for name, value in self._json.items():
            if name in self._properties:
                if '$ref' in self._properties[name]:
                    if 'decimal' in self._properties[name]['$ref']:
                        value = Decimal(value)

                # applying proper formatting when required
                if 'format' in self._properties[name]:
                    format = self._properties[name]['format']

                    if 'date-time' == format:
                        value = utils.string_to_datetime(value)
                    elif 'date' == format:
                        value = utils.string_to_date(value)
                setattr(self, name, value)
567800
def update(self, dictionary):
        """"""
        allowed_attrs = list(self.__attributes__.keys())
        allowed_attrs += [a.alias for a in self.__attributes__.values()]
        for k in dictionary:
            # We only update existing attributes
            if k in allowed_attrs:
                setattr(self, k, dictionary[k])
        return self
1264211
def load_json_from_string(string):
    """"""
    try:
        json_data = json.loads(string)
    except ValueError as e:
        raise ValueError('Given string is not valid JSON: {}'.format(e))
    else:
        return json_data
915033
def setDictionary(self, data):
		
		
		# Create the directory containing the JSON file if it doesn't already exist
		jsonDir = os.path.dirname(self.jsonFile)
		if os.path.exists(jsonDir) == False:
			os.makedirs(jsonDir)
		
		# Store the dictionary
		Utility.writeFile(self.jsonFile, json.dumps(data))
860290
def _set_attributes(self):
        
        # turn config dict into nested objects
        config = obj(self._config_dict)
        # set the attributes onto instance
        for k, v in self._config_dict.items():
            setattr(self, k, getattr(config, k))