Skip to main content

Yes, another config lang

Project description

ModCFG

YEs

codecov Documentation Status Code style: black CI

YEs, another configuration language

Seriously, how many configuration languages do we have? From the top of my head, I can only name:

Hmmm... that's it I think. wE NeEd MOrE cOnfIGURaTion LanGuaGEs!!1!1!!

But actually though

I originally based this off of the Ruby/DSL for homebrew formulas.

Here are my complaints for the alternatives:

  • JSON, while simple, isn't too readable and only has the bear minimum of datatypes. That may be a feature for some people, though.
  • YAML is dangerous. And unpredictable.
  • INI and TOML are quite similar and they both are quite nice with a lot of datatypes but, in my opinion, the format isn't as natural to read as YAML. TOML supports dates and datetime, though.
  • Finally, XML is garbage. It's barely human-readable and can decode into a super wonky format. So no.

Finally, I just wanted an excuse to play with Lark.

Features

  • Enums with a built-in resolver
  • Date time and Date support
  • YAML-like syntax
  • Support for comments, unicode escape sequences, string modifications, and cleanly managed indented strings

Examples

Given this modcfg document:

module hello_world:
    hello => world
    this: "also works"
    'single quotes' = "equals double quotes"
    how -> {
            about: {
                some:
                    - very
                    - crazy
                    - data:
                        structures = o_0
            }
        }

and this python script:

import modcfg
modcfg.loads(DOC)  # `DOC` is the document above

The output is

[
    Module(
        name="hello_world",
        contents=[
            {
                "hello": "world",
                "this": "also works",
                "single quotes": "equals double quotes",
                "how": {
                    "about": {
                        "some": ["very", "crazy", {"data": {"structures": "o_0"}}]
                    }
                },
            }
        ],
    )
]

Crazy, right? It gets better with enums and date(time)s... You might as well read the whole documentation.

Installation

$ pip install modcfg

Develop-install

The classic method:

$ git clone https://github.com/ThatXliner/modcfg.git
$ cd modcfg
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install -e .

The best method (requires Poetry):

$ git clone https://github.com/ThatXliner/modcfg.git
$ cd modcfg
$ poetry install

FAQ

Why did you make this

why

Lark is epic.

Why the name?

Modular Configuration language.

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

modcfg-0.1.3.tar.gz (22.9 kB view hashes)

Uploaded Source

Built Distribution

modcfg-0.1.3-py3-none-any.whl (22.0 kB view hashes)

Uploaded Python 3

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