Skip to main content

Settings framework for framework or library.

Project description

config framework

https://travis-ci.org/tsuyukimakoto/glueplate.svg?branch=master https://codecov.io/gh/tsuyukimakoto/glueplate/branch/master/graph/badge.svg https://pyup.io/repos/github/tsuyukimakoto/glueplate/shield.svg https://pyup.io/repos/github/tsuyukimakoto/glueplate/python-3-shield.svg https://codebeat.co/badges/bb625f2e-572a-410f-9019-08006aac86cf

What is Config framework?

Your framework or library might need default settings and you want your user to change them.

Many developer wrote this kind of code, and you are going to. GluePlate is it!

Features

Easy to write - Merge

You and your user write easiry.

Just import Glue as _ and write like nested dict.

from glueplate import Glue as _


settings = _(
    GLUE_PLATE_ENVIRONMENT_VARIABLE_KEY = 'BASEPACKAGE_SETTINGS_MODULE',
    from_base = 'comming from base',
    to_be_override = 'I am base.',
)

glueplate import variable named settings from os.environ[‘GLUE_PLATE_BASE_MODULE’], this is a base settings.

Then glueplate looks settings.GLUE_PLATE_ENVIRONMENT_VARIABLE_KEY and import variable named settings from os.environ[settings.GLUE_PLATE_ENVIRONMENT_VARIABLE_KEY], this is a user customized settings. Customized settings needs only user needs override, or addition.

from glueplate import Glue as _


settings = _(
    from_sub='comming from sub',
    to_be_override = 'I am sub.',
)

They are merged and easy to use.

from glueplate import config

assert('I am sub' == config.settings.to_be_override)
assert('comming from base' == config.settings.from_base)
assert('comming from sub' == config.settings.from_sub)

Append to list

You may not want to override by you user, just add user’s additional data.

glueplate provide special keyword prefix to append original settings variable.

  • GLUE_PLATE_PLUS_BEFORE_

    User can append list before.

    # base
    settings = _(
        list1 = [1,2,3],
    )
    
    # user customized
    settings = _(
        GLUE_PLATE_PLUS_BEFORE_list1 = [5,4]
    )
    
    # config.settings.list1 == [5, 4, 1, 2, 3]
  • GLUE_PLATE_PLUS_AFTER_

    Same as GLUE_PLATE_PLUS_BEFORE_ but append to backward.

    # base
    settings = _(
        list1 = [1,2,3],
    )
    
    # user customized
    settings = _(
        GLUE_PLATE_PLUS_AFTER_list1 = [5,4]
    )
    
    # config.settings.list1 == [1, 2, 3, 5, 4]

Inherit other glueplate

You might use library using glueplate. Environment variable GLUE_PLATE_BASE_MODULE is only one on your process.

Your base settings can indecate library’s gluplate settings module.

  • GLUE_PLATE_PARENT_MODULES

    Specify library’s gluplate settings module names as list.

    from glueplate import Glue as _
    
    
    settings = _(
        GLUE_PLATE_PARENT_MODULES=[
            'parentpackage1.parentpackage1_settings',
            'parentpackage2.parentpackage2_settings'
        ]
    )

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

glueplate-1.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

glueplate-1.1.0-py2.py3-none-any.whl (4.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file glueplate-1.1.0.tar.gz.

File metadata

  • Download URL: glueplate-1.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

File hashes

Hashes for glueplate-1.1.0.tar.gz
Algorithm Hash digest
SHA256 ecefefad679b5f2a7bb940186ff0e4b9a425b4d7129e78e54937857201e6a9da
MD5 8ea464768623ce4bdd5330ceb184d7f7
BLAKE2b-256 6eeaf19e53c3d6a18b100a22aa0685e2bf8f2d4d049c08753e08d4eb09c8ac20

See more details on using hashes here.

File details

Details for the file glueplate-1.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: glueplate-1.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

File hashes

Hashes for glueplate-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 af0edfe03bf418627fe1394fa039cc5147b9ec16439e7a1a58330f0e768893e5
MD5 8ee01a440ae68daf681580e809e5b5e7
BLAKE2b-256 709a295964307fc4ee9d4f580c1d51c31cbd5f8c99705ef59de564f161fb0166

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