Converts a list into a space-separated string and puts it in a dictionary

    :param key: Dictionary key to store the list
    :param list_: A list of objects
    :return: A dictionary key->string or an empty dictionary
4810
def encode_list(key, list_):
    # type: (str, Iterable) -> Dict[str, str]
    
    if not list_:
        return {}
    return {key: " ".join(str(i) for i in list_)}
610972
def dictlist_replace(dict_list: Iterable[Dict], key: str, value: Any) -> None:
    
    for d in dict_list:
        d[key] = value
1311504
def _get(self, key, parser_result):
        
        try:
            list_data = parser_result[key].asList()
            if any(isinstance(obj, str) for obj in list_data):
                txt_lines = [''.join(list_data)]
            else:
                txt_lines = [''.join(f) for f in list_data]
        except KeyError:
            txt_lines = []
        return txt_lines
1205613
def _storage_list_keys(bucket, pattern):
  
  data = [{'Name': item.metadata.name,
           'Type': item.metadata.content_type,
           'Size': item.metadata.size,
           'Updated': item.metadata.updated_on}
          for item in _storage_get_keys(bucket, pattern)]
  return datalab.utils.commands.render_dictionary(data, ['Name', 'Type', 'Size', 'Updated'])
264182
def key_from_dict(**kwargs):
    
    out = []
    stack = [kwargs]
    while stack:
        obj = stack.pop()
        if isinstance(obj, dict):
            stack.extend(sorted(obj.items()))
        elif isinstance(obj, (list, tuple)):
            stack.extend(obj)
        else:
            out.append(str(obj))
    return ''.join(out)
283750
def _dict_to_string(dictionary):
    '''
    
    '''
    ret = ''
    for key, val in sorted(dictionary.items()):
        if isinstance(val, dict):
            for line in _dict_to_string(val):
                ret += six.text_type(key) + '-' + line + '\n'
        elif isinstance(val, list):
            text = ' '.join([six.text_type(item) for item in val])
            ret += six.text_type(key) + ': ' + text + '\n'
        else:
            ret += six.text_type(key) + ': ' + six.text_type(val) + '\n'
    return ret.splitlines()
898751
def get_string_list(self, key):
        """"""
        strings = []
        size = self.beginReadArray(key)
        for i in range(size):
            self.setArrayIndex(i)
            entry = str(self._value("entry"))
            strings.append(entry)
        self.endArray()
        return strings
409873
def getlist(self, key, delimiter=',', **kwargs):
        

        value = self.get(key, **kwargs)
        if value is None: return value
        if isinstance(value, str):
            value = value.strip()
            if value.startswith('[') and value.endswith(']'):
                return self.getserialized(key)

            return [p.strip(' ') for p in value.split(delimiter)]
        #end if

        return list(value)
1365236
def _decode_list(data):
    
    if six.PY3:
        return data
    rv = []
    for item in data:
        if not isinstance(item, text_type):
            item = item.encode('utf-8')
        elif isinstance(item, list):
            item = _decode_list(item)
        rv.append(item)
    return rv
1188610
def encode_keys(self, keys):
        
        return dict(((k, self.encode(v)) for k, v in six.iteritems(keys) if not
                     is_null(v)))
806862
def _list_to_set(self, list_key, set_key):
        
        if self.cls.database.support_scripting():
            self.cls.database.call_script(
                # be sure to use the script dict at the class level
                # to avoid registering it many times
                script_dict=self.__class__.scripts['list_to_set'],
                keys=[list_key, set_key]
            )
        else:
            conn = self.cls.get_connection()
            conn.sadd(set_key, *conn.lrange(list_key, 0, -1))
975850
def encode_list(data, encoding=None, errors='strict', keep=False,
                preserve_dict_class=False, preserve_tuples=False):
    '''
    
    '''
    rv = []
    for item in data:
        if isinstance(item, list):
            item = encode_list(item, encoding, errors, keep,
                               preserve_dict_class, preserve_tuples)
        elif isinstance(item, tuple):
            item = encode_tuple(item, encoding, errors, keep, preserve_dict_class) \
                if preserve_tuples \
                else encode_list(item, encoding, errors, keep,
                                 preserve_dict_class, preserve_tuples)
        elif isinstance(item, Mapping):
            item = encode_dict(item, encoding, errors, keep,
                               preserve_dict_class, preserve_tuples)
        else:
            try:
                item = salt.utils.stringutils.to_bytes(item, encoding, errors)
            except TypeError:
                # to_bytes raises a TypeError when input is not a
                # string/bytestring/bytearray. This is expected and simply
                # means we are going to leave the value as-is.
                pass
            except UnicodeEncodeError:
                if not keep:
                    raise

        rv.append(item)
    return rv
120711
def format_dict(dic, format_list, separator=',', default_value=str):
    

    dic = collections.defaultdict(default_value, dic)

    str_format = separator.join(["{" + "{}".format(head) + "}" for head in format_list])

    return str_format.format(**dic)
74869
def prepend_to_list(self, key, *value, pipeline=False):
        
        if pipeline:
            self._pipeline.lpush(key, *value)
        else:
            self._db.lpush(key, *value)
1227845
def _asciify_list(data):
    
    ret = []
    for item in data:
        if isinstance(item, unicode):
            item = _remove_accents(item)
            item = item.encode('utf-8')
        elif isinstance(item, list):
            item = _asciify_list(item)
        elif isinstance(item, dict):
            item = _asciify_dict(item)
        ret.append(item)
    return ret
319405
def serialize(self, items):
        
        r = StringIO()
        for key, value in items.items():
            if isinstance(value, list):
                # handle special case of lists
                value = "["+", ".join(map(str, value))+"]"
            r.write("%s = %s\n" % (key, value))
        return r.getvalue()
1227084
def _convert_key_to_str(key):
    '''
    
    '''
    # IMPORTANT: on PY2, the secret key must be str and not unicode to work
    # properly with hmac.new (see http://bugs.python.org/issue5285)
    #
    # pylint: disable=incompatible-py3-code,undefined-variable
    return salt.utils.data.encode(key) \
        if six.PY2 and isinstance(key, unicode) \
        else key