GithubHelp home page GithubHelp logo

confight's People

Contributors

davidesba avatar ffapitalle avatar frank-lenormand avatar jvrsantacruz avatar matiasditada avatar quimey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

confight's Issues

Giv full controll of the stream to the loaders

The file loaders get passed a stream object that was opened by confight.

When overriding a loader for a given format, this might be an issue if the stream is expected to be opened with specific options, or even if the underlying loader implementation doesn’t accept a stream (e.g. only a file path).

Example: tomllib.load() expects the stream to be opened in rb mode, but confight passes a stream opened in r mode to the loader.

Support `$XDG_CONFIG_HOME`

The default location for the user configuration should be:

${XDG_CONFIG_HOME:-${HOME}/config}/app/config.toml

Make sure a function to recursively merge dictionaries is accessible and documented

This request might not require any effort to fulfil, I haven’t checked the code.

Recursively merging Python dictionaries is an (ever) unsolved problem, on the side of the standard library.

Confight deals with dictionaries, and the community could benefit from its dictionary merging capabilities.

For example:

from confight import merge_dictionaries
merge_dictionaries(defaults, user_config)

Make sure the function is exported and documented.

YAML is not supported, but declared

Docs are specifying support of YAML, but it is not supported (At least in the version that is shipped by the pip by default.).
image

Here is the code fragment from confight.py

FORMATS = ('toml', 'ini', 'json')
FORMAT_EXTENSIONS = {
    'js': 'json',
    'json': 'json',
    'toml': 'toml',
    'ini': 'ini',
    'cfg': 'ini',
}
FORMAT_LOADERS = {
    'json': lambda *args: json.load(*args, object_pairs_hook=OrderedDict),
    'toml': lambda *args: toml.load(*args, _dict=OrderedDict),
    'ini': load_ini
}

The attempt to parse YAML config results in

ValueError: Unknown format extension 'yaml' for '/etc/<app>/config.yaml'

Add support for /usr/share config files

Nowadays it is very common to have config files in three different places:

  1. /usr/share/app. These are the config files that come with the distro package. Different packages can provide config droplets to other packages. They should never be changed by the user, so that package upgrades can work without conflicts.
  2. /etc/app. These are the machine-installation-specific config files. They win over 1, so any customization for your local installation goes in here.
  3. ~/.config/app. These are user-specific config files. They win over 1 and 2.

Make the TOML loaded to use `tomllib` with Python ≥3.11 by default

The toml library used by confight still doesn’t fully comply with the TOML v1.0.0 specification, and seems abandoned.

Example of problematic shortcoming (several years old) that still isn’t fixed:

Python v3.11 has introduced a library for TOML parsing (read-only): tomllib.

It’s not clear if using tomllib over toml would be a net benefit (trading a set of bugs for another is not ideal).

There’s a good chance that using tomllib by default when Python ≥3.11 is used as an interpreter will be beneficial if not now, at least long-term.

Implement merging strategies

Related to #14.

It would be nice to be able to specify a merging strategy to guide Confight as to what its expected behaviour would be when merging two dictionaries.

Examples include:

  • merging lists
  • ignoring the right hand value if the left hand value isn’t set (i.e. only update, no upsert)
  • replacing the entire left hand dictionary with an existing right hand dictionary (i.e. the default behaviour of {**left, **right})
  • matcher objects that dynamically set a strategy, predicated on the current key/dictionary being processed

Support Python v3.8+ only

The list of supported Python versions seems outdated (v2.7 + v3.4 - v3.7).

The codebase should be overhauled to support ideally Python v3.6+, more realistically v3.8+ (to v3.11 would be enough for now).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.