def to_yaml(cls, config, compact=False, indent=2, level=0):
        """Convert HOCON input into a YAML output

        :return: YAML string representation
        :type return: basestring
        """
        lines = ""
        if isinstance(config, ConfigTree):
            if len(config) > 0:
                if level > 0:
                    lines += '\n'
                bet_lines = []
                for key, item in config.items():
                    bet_lines.append('{indent}{key}: {value}'.format(
                        indent=''.rjust(level * indent, ' '),
                        key=key.strip('"'),  # for dotted keys enclosed with "" to not be interpreted as nested key,
                        value=cls.to_yaml(item, compact, indent, level + 1))
                    )
                lines += '\n'.join(bet_lines)
        elif isinstance(config, list):
            config_list = [line for line in config if line is not None]
            if len(config_list) == 0:
                lines += '[]'
            else:
                lines += '\n'
                bet_lines = []
                for item in config_list:
                    bet_lines.append('{indent}- {value}'.format(indent=''.rjust(level * indent, ' '),
                                                                value=cls.to_yaml(item, compact, indent, level + 1)))
                lines += '\n'.join(bet_lines)
        elif isinstance(config, basestring):
            # if it contains a \n then it's multiline
            lines = config.split('\n')
            if len(lines) == 1:
                lines = config
            else:
                lines = '|\n' + '\n'.join([line.rjust(level * indent, ' ') for line in lines])
        elif config is None or isinstance(config, NoneValue):
            lines = 'null'
        elif config is True:
            lines = 'true'
        elif config is False:
            lines = 'false'
        else:
            lines = str(config)
        return lines
def to_yaml ( cls , config , compact = False , indent = 2 , level = 0 ) : lines = "" if isinstance ( config , ConfigTree ) : if len ( config ) > 0 : if level > 0 : lines += '\n' bet_lines = [ ] for key , item in config . items ( ) : bet_lines . append ( '{indent}{key}: {value}' . format ( indent = '' . rjust ( level * indent , ' ' ) , key = key . strip ( '"' ) , value = cls . to_yaml ( item , compact , indent , level + 1 ) ) ) lines += '\n' . join ( bet_lines ) elif isinstance ( config , list ) : config_list = [ line for line in config if line is not None ] if len ( config_list ) == 0 : lines += '[]' else : lines += '\n' bet_lines = [ ] for item in config_list : bet_lines . append ( '{indent}- {value}' . format ( indent = '' . rjust ( level * indent , ' ' ) , value = cls . to_yaml ( item , compact , indent , level + 1 ) ) ) lines += '\n' . join ( bet_lines ) elif isinstance ( config , basestring ) : lines = config . split ( '\n' ) if len ( lines ) == 1 : lines = config else : lines = '|\n' + '\n' . join ( [ line . rjust ( level * indent , ' ' ) for line in lines ] ) elif config is None or isinstance ( config , NoneValue ) : lines = 'null' elif config is True : lines = 'true' elif config is False : lines = 'false' else : lines = str ( config ) return lines
Convert HOCON input into a YAML output

        :return: YAML string representation
        :type return: basestring