Skip to content

Add support for "global" properties (before any section)? #123

Description

@Delgan

Describe your use-case

Hi again.

I implemented a library on top of configupdater and someone reported it didn't work with EditorConfig configuration files. This is because such file can contain "global" properties which declared before any section:

root = true

[section]
foo = bar
baz = 42

There are no definitive specifications on the acceptable syntax of an INI file. In that respect, configupdater is consistent with configparser since both reject such file and raise MissingSectionHeaderError error.

Given that there are certain variants of the INI format that accept global parameters (also Apache), what do you think about extending configupdater support to such files?

Describe the solution you would like to see for your use-case

I imagine a new option to the ConfigUpdater class, such as allow_global_parameters defaulting to False. If True, the global parameters would be added to a section with None name or something like that.

I can try to open a PR if you're interested with such feature (don't know how technically feasible it is yet).

Otherwise, I'll just hack a workaround in my own library. But since it may be beneficial to others, I wanted to discuss it upstream first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions