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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file modcfg-0.1.3.tar.gz.

File metadata

  • Download URL: modcfg-0.1.3.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.6.12 Darwin/19.6.0

File hashes

Hashes for modcfg-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3ccb0a228d86879c63d35fe7b52002bbb66206ca5707890f0f4ccd1fdd3e97e0
MD5 b5b128127f5b2f795625fe11ea5432f7
BLAKE2b-256 8ad281fbfca8582d234ad790a68a115b2228e55b1840115154ec7248092a601f

See more details on using hashes here.

File details

Details for the file modcfg-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: modcfg-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.6.12 Darwin/19.6.0

File hashes

Hashes for modcfg-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 71f0ea40b2f72cc05b116f12aff072824e05338d1593802b9df7f14d60506d3c
MD5 dedda3be8dc96090249f47ba59d9da43
BLAKE2b-256 b611817703287404adc39b5cb72d0707841518a30a46b30149aba32efed7ac61

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