Convert a dict form of query in a string of needed and store the query string.

            Args:
                value -- A query string or a dict with query xpaths as keys and text or
                        nested query dicts as values.
543175
def set_query(self, value):
        
        if isinstance(value, basestring) or value is None:
            self._content['query'] = value
        elif hasattr(value, 'keys'):
            self._content['query'] = query.terms_from_dict(value)
        else:
            raise TypeError("Query must be a string or dict. Got: " + type(value) + " insted!")
326366
def to_python(self, value):
        
        if self.blank and not value:
            return {}
        value = value or '{}'
        if isinstance(value, six.binary_type):
            value = six.text_type(value, 'utf-8')
        if isinstance(value, six.string_types):
            try:
                # with django 1.6 i have '"{}"' as default value here
                if value[0] == value[-1] == '"':
                    value = value[1:-1]

                return json.loads(value)
            except Exception as err:
                raise ValidationError(str(err))
        else:
            return value
1135071
def from_dict(self, value):
        
        for key in self.keys():
            setattr(self, key, value.get(key, None))
251052
def _format_param_value(key, value):
    
    if isinstance(value, str):
        value = "'{}'".format(value)
    return "{}={}".format(key, value)
981031
def query_to_map(text):
    '''
    '''
    dict_obj = {}

    for key, value in split_query(text, True):
        if key not in dict_obj:
            dict_obj[key] = []

        if value:
            dict_obj[key].append(value.replace('+', ' '))
        else:
            dict_obj[key].append('')

    return query_to_map(text)
57433
def _dictify(field, value):
    
    if value is None:
        return None
    elif field.type_:
        return value.to_dict()
    return field.dict_value(value)
1209281
def make_value_from_datastore(self, value):
    

    if value is None:
      return None
    _json = json.loads(value, cls=JsonDecoder)
    if self.data_type == dict:
      return _json
    return self.data_type.from_json(_json)
1011713
def set(self, value):
        

        if not isinstance(value, str_cls):
            raise TypeError(unwrap(
                '''
                %s value must be a unicode string, not %s
                ''',
                type_name(self),
                type_name(value)
            ))

        if value.startswith('.'):
            encoded_value = b'.' + value[1:].encode(self._encoding)
        else:
            encoded_value = value.encode(self._encoding)

        self._unicode = value
        self.contents = encoded_value
        self._header = None
        if self._trailer != b'':
            self._trailer = b''
726353
def find(self, value):
        
        value = str(value).lower()
        rtn_dict = RegistryDictionary()
        for key, item in self.items():
            if value in key.lower():
                rtn_dict[key] = item
        return rtn_dict
1112764
def parse_query_string(query):
    
    result = {}
    qparts = query.split('&')
    for item in qparts:
        key, value = item.split('=')
        key = key.strip()
        value = value.strip()
        result[key] = unquote_plus(value)
    return result
599660
def _set_value(value):
    '''
    
    '''
    #don't continue if already an acceptable data-type
    if isinstance(value, bool) or isinstance(value, dict) or isinstance(value, list):
        return value

    #check if json
    if value.startswith('j{') and value.endswith('}j'):

        value = value.replace('j{', '{')
        value = value.replace('}j', '}')

        try:
            return salt.utils.json.loads(value)
        except Exception:
            raise salt.exceptions.CommandExecutionError

    #detect list of dictionaries
    if '|' in value and r'\|' not in value:
        values = value.split('|')
        items = []
        for value in values:
            items.append(_set_value(value))
        return items

    #parse out dictionary if detected
    if ':' in value and r'\:' not in value:
        options = {}
        #split out pairs
        key_pairs = value.split(',')
        for key_pair in key_pairs:
            k = key_pair.split(':')[0]
            v = key_pair.split(':')[1]
            options[k] = v
        return options

    #try making a list
    elif ',' in value and r'\,' not in value:
        value_items = value.split(',')
        return value_items

    #just return a string
    else:

        #remove escape chars if added
        if r'\|' in value:
            value = value.replace(r'\|', '|')

        if r'\:' in value:
            value = value.replace(r'\:', ':')

        if r'\,' in value:
            value = value.replace(r'\,', ',')

        return value
188266
def python_value(self, value):
        
        value = super(JSONField, self).python_value(value)

        if value is not None:
            return flask.json.loads(value, **self._load_kwargs)
693507
def find(value):
        
        value = str(value).lower()
        rtn_dict = RegistryDictionary()
        for attr in dir(MODULE.rdfclass):
            if value in attr.lower():
                try:
                    item = getattr(MODULE.rdfclass, attr)
                    if issubclass(item, RdfClassBase):
                        rtn_dict[attr] = item
                except TypeError:
                    pass
        return rtn_dict
305705
def encode(cls, value):
        
        try:
            coerced = dict(value)
            if coerced == value:
                return json.dumps(coerced).encode(cls._encoding)
        except (TypeError, ValueError):
            pass
        raise InvalidValue('not a dict')
87539
def encode(cls, value):
        
        try:
            coerced = [str(v) for v in value]
            if coerced == value:
                return ",".join(coerced).encode(cls._encoding) if len(
                    value) > 0 else None
        except TypeError:
            pass

        raise InvalidValue('not a list of strings')
1073933
def contains(self, value):
        
        str_value = StringConverter.to_nullable_string(value)

        for element in self:
            str_element = StringConverter.to_string(element)

            if str_value == None and str_element == None:
                return True
            if str_value == None or str_element == None:
                continue
            
            if str_value == str_element:
                return True

        return False
217483
def query_params(self, value=None):
        
        if value is not None:
            return URL._mutate(self, query=unicode_urlencode(value, doseq=True))
        query = '' if self._tuple.query is None else self._tuple.query

        # In Python 2.6, urlparse needs a bytestring so we encode and then
        # decode the result.
        if not six.PY3:
            result = parse_qs(to_utf8(query), True)
            return dict_to_unicode(result)

        return parse_qs(query, True)