Skip to main content

Manage multiple TOML configurations from a single module.

Project description

mtoml

Manage multiple TOML configurations from a single module.

pip install mtoml

codefactor circleci codecov

from mtoml import mtoml

class pets(mtoml):
    def __init__(self):
        mtoml.__init__('.\PATH_TO_CONFIGS\')  # set the relative path to the config directory, defaults to the current directory or a previously set directory

        if not self.is_loaded('dogs'):  # all instances share the same files
            self.load('dogs')  # load a config file named "dogs.toml"

        if not self.is_loaded('cats'):
            self.load('cats')  # load a config file named "cats.toml"

        # this module should not throw any exceptions, if a method fails it returns either False or None.

        self.conf = mtoml('.\PATH_TO_CONFIGS\')  # this is also valid; self.conf.load(), self.conf.is_loaded(), etc

    def __del__(self):
        self.save_all()  # save all loaded configs

    def add_new_dog_breed(self, breed):
        dog_breeds = self.get('dogs', 'breeds')  # gets the current list of dog breeds
        dog_breeds.append(breed)                 # we are assuming it returned a list for brevity but if 'get' fails it returns None
        self.set('dogs', 'breeds', dog_breeds)   # sets the variable 'breeds' in the config 'dogs' to our new list

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mtoml-1.0.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

mtoml-1.0.0-py2.py3-none-any.whl (9.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file mtoml-1.0.0.tar.gz.

File metadata

  • Download URL: mtoml-1.0.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for mtoml-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1d2fcc063d3fa76ea8f74fd7a5c5d243a52c0b30210916900c89454fd298edf0
MD5 887dc4790fc36b0a0bfee2554e7a5d5f
BLAKE2b-256 1d9d63c3adc319c9b1f98e66e7bb33cdd23d97881be0ca59350193d37a22ffc0

See more details on using hashes here.

File details

Details for the file mtoml-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: mtoml-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for mtoml-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 44a269d094f4b8a951d52bcb001b5a64cf7058de3015e8148fcf72ab348c9138
MD5 636d8bb026e7c6671be3dd8050ef6e04
BLAKE2b-256 3c33922b5ba0ac5b85dd35b6a5bebc5e9fd638306e00e17511e18349e06f65b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page