Giter Club home page Giter Club logo

modcfg's Introduction

ModCFG

YEs

codecov Documentation Status Code style: black CI PyPI

YEs, another configuration language

A whitespace-sensitive configuration language and data format.


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.

modcfg's People

Contributors

thatxliner avatar deepsourcebot avatar imgbotapp avatar

Watchers

 avatar  avatar

modcfg's Issues

Change short description

From "YEs, another configuration language" to "A whitespace-sensitive configuration language and data format."

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.