Skip to main content

Build Status PyPi version Code style: black

miniconfig

making configuration phase, in your application. (Tiny version of almost pyramid's configurator object)

# yourapp/__init__.py
from miniconfig import ConfiguratorCore


class Configurator(ConfiguratorCore):
    def make_app(self):
        self.commit()
        return App(self.settings)


class App:
    def __init__(self, settings):
        self.settings = settings

yourapp/pluginA.py

class A:
    pass


def includeme(config):
    config.settings["A"] = A()

yourapp/pluginB.py

class B:
    pass


def includeme(config):
    config.include(".pluginA")
    config.settings["B"] = B()

application user

from yourapp import Configurator

config = Configurator()
config.include("yourapp.pluginB")
app = config.make_app()
print(app.settings.keys())  # dict_keys(['A', 'B'])

Adding directives

directive means that action of configurator.

how to define and use directive

def hello(config, name):
    def register():
        assert config.settings["foo"] == "foo"
        print("hello: {}".format(name))
    discriminator = (hello, name)
    config.action(discriminator, register)


config = Configurator(settings={"foo": "foo"})
config.add_directive("hello", hello)
config.hello("foo")

it is also supported that to define directives by dotted name

foo/bar.py

def hello(config):
    def register():
        print("hai")
    discriminator = id(object())  # xxx
    config.action(discriminator, register)

yourapp

config = Configurator()
config.add_directive("hello", "foo.bar:hello")
config.hello()
config.commit() # hai

Metadata

Release files for miniconfig 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for miniconfig 0.6.0
File Interpreter ABI Platform Actions
miniconfig-0.6.0-py3-none-any.whl Python 3 none any Details for miniconfig-0.6.0-py3-none-any.whl

Release files / miniconfig-0.6.0-py3-none-any.whl

Download URL miniconfig-0.6.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
036577ff1d4693fefb28d132b2c2c8aedc5bdc93e3068d28ad3bfbda7f523a14
BLAKE2b-256 checksum
How to use checksums
2e47d274e81e2382db1aa574835b14a8d88b607821b8981bd2ade7e934ec33bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.2

Security for miniconfig 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page