goodconf/__init__.py
def generate_yaml(cls, **override):
        """
        Dumps initial config in YAML
        """
        import ruamel.yaml
        yaml = ruamel.yaml.YAML()
        yaml_str = StringIO()
        yaml.dump(cls.get_initial(**override), stream=yaml_str)
        yaml_str.seek(0)
        dict_from_yaml = yaml.load(yaml_str)
        if cls.__doc__:
            dict_from_yaml.yaml_set_start_comment(
                '\n' + cls.__doc__ + '\n\n')
        for k in dict_from_yaml.keys():
            if cls._values[k].help:
                dict_from_yaml.yaml_set_comment_before_after_key(
                    k, before='\n' + cls._values[k].help)
        yaml_str = StringIO()
        yaml.dump(dict_from_yaml, yaml_str)
        yaml_str.seek(0)
        return yaml_str.read()
def generate_yaml(cls, **override):
        import ruamel.yaml
        yaml = ruamel.yaml.YAML()
        yaml_str = StringIO()
        yaml.dump(cls.get_initial(**override), stream=yaml_str)
        yaml_str.seek(0)
        dict_from_yaml = yaml.load(yaml_str)
        if cls.__doc__:
            dict_from_yaml.yaml_set_start_comment(
                '\n' + cls.__doc__ + '\n\n')
        for k in dict_from_yaml.keys():
            if cls._values[k].help:
                dict_from_yaml.yaml_set_comment_before_after_key(
                    k, before='\n' + cls._values[k].help)
        yaml_str = StringIO()
        yaml.dump(dict_from_yaml, yaml_str)
        yaml_str.seek(0)
        return yaml_str.read()
def generate_yaml ( cls , * * override ) : import ruamel . yaml yaml = ruamel . yaml . YAML ( ) yaml_str = StringIO ( ) yaml . dump ( cls . get_initial ( * * override ) , stream = yaml_str ) yaml_str . seek ( 0 ) dict_from_yaml = yaml . load ( yaml_str ) if cls . __doc__ : dict_from_yaml . yaml_set_start_comment ( '\n' + cls . __doc__ + '\n\n' ) for k in dict_from_yaml . keys ( ) : if cls . _values [ k ] . help : dict_from_yaml . yaml_set_comment_before_after_key ( k , before = '\n' + cls . _values [ k ] . help ) yaml_str = StringIO ( ) yaml . dump ( dict_from_yaml , yaml_str ) yaml_str . seek ( 0 ) return yaml_str . read ( )
Dumps initial config in YAML
Dumps initial config in YAML