Convert a dict to a multi-line stanza
767432
def _dict_to_stanza(key, stanza):
    '''
    
    '''
    ret = ''
    for skey in stanza:
        if stanza[skey] is True:
            stanza[skey] = ''
        ret += '    {0} {1}\n'.format(skey, stanza[skey])
    return '{0} {{\n{1}}}'.format(key, ret)
555614
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'logs' in _dict:
            args['logs'] = [Log._from_dict(x) for x in (_dict.get('logs'))]
        else:
            raise ValueError(
                'Required property \'logs\' not present in LogCollection JSON')
        if 'pagination' in _dict:
            args['pagination'] = LogPagination._from_dict(
                _dict.get('pagination'))
        else:
            raise ValueError(
                'Required property \'pagination\' not present in LogCollection JSON'
            )
        return cls(**args)
1174443
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'results' in _dict:
            args['results'] = [
                LogQueryResponseResultDocumentsResult._from_dict(x)
                for x in (_dict.get('results'))
            ]
        if 'count' in _dict:
            args['count'] = _dict.get('count')
        return cls(**args)
171250
def _multiline_convert(config, start="banner login", end="EOF", depth=1):
        """"""
        ret = list(config)  # Don't modify list in-place
        try:
            s = ret.index(start)
            e = s
            while depth:
                e = ret.index(end, e + 1)
                depth = depth - 1
        except ValueError:  # Couldn't find end, abort
            return ret
        ret[s] = {"cmd": ret[s], "input": "\n".join(ret[s + 1 : e])}
        del ret[s + 1 : e + 1]

        return ret
1237049
def crude_tokenizer(line):
    """"""
    tokens = []
    buffer = ''
    for c in line.strip():
        if c == ' ' or c in string.punctuation:
            if buffer:
                tokens.append(buffer)
                buffer = ''
        else:
            buffer += c
    if buffer: tokens.append(buffer)
    return tokens
394247
def translate_dict(cls, val):
        """"""
        escaped = ', '.join(
            ["{} -> {}".format(cls.translate_str(k), cls.translate(v)) for k, v in val.items()]
        )
        return 'Map({})'.format(escaped)
560388
def process_repeated_list(self, key, lst, level):
        
        lines = []

        for v in lst:
            k = key.upper()
            v = self.quoter.add_quotes(v)
            lines.append(self.__format_line(self.whitespace(level, 1), k, v))

        return lines
627859
def convert_dict(obj, ids, parent, attr_type, item_func, cdata):
    """"""
    LOG.info('Inside convert_dict(): obj type is: "%s", obj="%s"' % (
        type(obj).__name__, unicode_me(obj))
    )
    output = []
    addline = output.append
    
    item_name = item_func(parent)
    
    for key, val in obj.items():
        LOG.info('Looping inside convert_dict(): key="%s", val="%s", type(val)="%s"' % (
            unicode_me(key), unicode_me(val), type(val).__name__)
        )

        attr = {} if not ids else {'id': '%s' % (get_unique_id(parent)) }

        key, attr = make_valid_xml_name(key, attr)

        if isinstance(val, numbers.Number) or type(val) in (str, unicode):
            addline(convert_kv(key, val, attr_type, attr, cdata))

        elif hasattr(val, 'isoformat'): # datetime
            addline(convert_kv(key, val.isoformat(), attr_type, attr, cdata))

        elif type(val) == bool:
            addline(convert_bool(key, val, attr_type, attr, cdata))

        elif isinstance(val, dict):
            if attr_type:
                attr['type'] = get_xml_type(val)
            addline('<%s%s>%s</%s>' % (
                key, make_attrstring(attr), 
                convert_dict(val, ids, key, attr_type, item_func, cdata), 
                key
                )
            )

        elif isinstance(val, collections.Iterable):
            if attr_type:
                attr['type'] = get_xml_type(val)
            addline('<%s%s>%s</%s>' % (
                key, 
                make_attrstring(attr), 
                convert_list(val, ids, key, attr_type, item_func, cdata), 
                key
                )
            )

        elif val is None:
            addline(convert_none(key, val, attr_type, attr, cdata))

        else:
            raise TypeError('Unsupported data type: %s (%s)' % (
                val, type(val).__name__)
            )

    return ''.join(output)
1134327
def tokenstream(self, data_dict):
        
        tokens = []
        self.execute(data_dict, tokens.append)
        for token in tokens:
            yield token
358259
def stringify_dict_contents(dct):
    """"""
    return {
        str_if_nested_or_str(k): str_if_nested_or_str(v)
        for k, v in dct.items()
    }
15855
def repr_dict(_dict, indent):
    """"""
    # pprint represents OrderedDict objects using the tuple init syntax,
    # which is not very readable. Therefore, dictionaries are iterated over.
    if _dict is None:
        return 'None'
    if not isinstance(_dict, Mapping):
        raise TypeError("Object must be a mapping, but is a %s" %
                        type(_dict))
    if isinstance(_dict, OrderedDict):
        kind = 'ordered'
        ret = '%s {\n' % kind  # non standard syntax for the kind indicator
        for key in six.iterkeys(_dict):
            value = _dict[key]
            ret += _indent('%r: %r,\n' % (key, value), 2)
    else:  # dict
        kind = 'sorted'
        ret = '%s {\n' % kind  # non standard syntax for the kind indicator
        for key in sorted(six.iterkeys(_dict)):
            value = _dict[key]
            ret += _indent('%r: %r,\n' % (key, value), 2)
    ret += '}'
    ret = repr_text(ret, indent=indent)
    return ret.lstrip(' ')
782979
def dict_to_literal(dict_container: dict):
    
    if isinstance(dict_container["@value"], int):
        return dict_container["@value"],
    else:
        return dict_container["@value"], dict_container.get("@language", None)
847444
def stringify(data):
    """"""
    if isinstance(data, dict):
        for key, value in data.items():
            data[key] = stringify(value)
    elif isinstance(data, list):
        return [stringify(item) for item in data]
    else:
        return smart_text(data)

    return data
1333856
def __clean_dict(dictionary):
        
        key_dict = {}
        value_dict = {}
        final_list = []
        for key in dictionary.keys():
            key_dict[key] = "seq"

        for value in dictionary.values():
            value_dict[value] = "text"

        for (key1, value1), (key2, value2) in zip(key_dict.items(), value_dict.items()):
            final_list.append({value1: int(key1), value2: key2})

        return final_list
331116
def pretty_dict_str(d, indent=2):
    """"""
    b = StringIO()
    write_pretty_dict_str(b, d, indent=indent)
    return b.getvalue()
990207
def parse_keypair_lines(content, delim='|', kv_sep='='):
    
    r = []
    if content:
        for row in [line for line in content if line]:
            item_dict = {}
            for item in row.split(delim):
                key, value = [i.strip("'\"").strip() for i in item.strip().split(kv_sep)]
                item_dict[key] = value
            r.append(item_dict)
    return r
117777
def _pprint_features_dict(features_dict, indent=0, add_prefix=True):
  """"""
  first_last_indent_str = " " * indent
  indent_str = " " * (indent + 4)
  first_line = "%s%s({" % (
      first_last_indent_str if add_prefix else "",
      type(features_dict).__name__,
  )
  lines = [first_line]
  for k in sorted(list(features_dict.keys())):
    v = features_dict[k]
    if isinstance(v, tfds.features.FeaturesDict):
      v_str = _pprint_features_dict(v, indent + 4, False)
    else:
      v_str = str(v)
    lines.append("%s'%s': %s," % (indent_str, k, v_str))
  lines.append("%s})" % first_last_indent_str)
  return "\n".join(lines)