Giter Club home page Giter Club logo

simple-toml-settings's Introduction

Simple TOML Settings

PyPI version Tests codecov Codacy Badge CodeQL

A Python library to save your settings in a TOML file.

Development software

Note that this library is still in the early stages of development and may contain bugs and/or change in the future. Please report any bugs you find on the issue tracker and feel free to make suggestions for improvements.

Installation

You should install this package into a virtual environment. You can use Poetry to do this:

$ poetry add simple-toml-settings

If you don't want to use Poetry, you can use pip from inside your virtual environment:

$ pip install simple-toml-settings

Usage

This is a library to save your settings in a TOML file. It is designed to be simple to use and to be able to save and load settings from a TOML file with a minimal of configuration.

The below is a minimal example, for full documentation and information on available options, see the documentation site.

Usage is simple:

Setup

from simple_toml_settings import TOMLSettings

class MySettings(TOMLSettings):
    """My settings class."""

    # Define the settings you want to save
    name: str = "My Name"
    age: int = 42
    favourite_colour: str = "blue"
    favourite_number: int = 42
    favourite_foods: list = ["pizza", "chocolate", "ice cream"]


settings = MySettings("test_app")

The above will automatically create a TOML file in the user's home directory called config.toml and save the settings to it. If the file already exists, the settings will be loaded from it.

The file contents for the above example would be:

[test_app]
age = 42
favourite_colour = "blue"
favourite_number = 42
name = "My Name"
schema_version = "none"
favourite_foods = ["pizza", "chocolate", "ice cream"]

Using the settings

Once you have created your settings class, you can use it like any other class:

settings = MySettings("test_app")
settings.favourite_colour = "red"
settings.save()

Note that the current library access methods are not set in stone and may change in the future. We will try to keep the changes to a minimum and will provide a migration path (and backwards compatibility) if we do change them.

Development setup

See the Contributing Guidelines for details of how to contribute to this project and set in up for development.

License

This project is released under the terms of the MIT license.

Credits

The original Python boilerplate for this package was created using Pymaker by Grant Ramsay (seapagan)

simple-toml-settings's People

Contributors

dependabot[bot] avatar seapagan avatar

Watchers

 avatar  avatar

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.