toylang on yaml or json
Python Makefile
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
examples
misc
scripts
tests
zenmai
.gitignore
.travis.yml
CHANGES.txt
LICENSE
MANIFEST.in
Makefile
README.rst
__init__.py
fastentrypoints.py
setup.cfg
setup.py

README.rst

zenmai

https://travis-ci.org/podhmo/zenmai.svg?branch=master

toylang on yaml or json

command line example

main.yaml

code:
  $import: ./filters.py
  as: f
definitions:
  $let:
    nums: {$load: ./nums.yaml#/definitions/nums0/enum}
  odds:
    type: integer
    enum:
      $f.odds: {$get: nums}
  even:
    type: integer
    enum:
      $f.evens: {$get: nums}

nums.yaml

definitions:
  nums0:
    type: integer
    enum:
      [1, 2, 3, 4, 5, 6]
  nums1:
    type: integer
    enum:
      [1, 2, 3, 5, 7, 11]

filters.py

def odds(nums):
    return [n for n in nums if n % 2 == 1]


def evens(nums):
    return [n for n in nums if n % 2 == 0]

run.

$ zenmai examples/readme2/main.yaml

output

zenmai main.yaml
definitions:
  odds:
    type: integer
    enum:
    - 1
    - 3
    - 5
  even:
    type: integer
    enum:
    - 2
    - 4
    - 6

config loader

using zenmai as config loader.

from zenma.loader import load

with open("config.yaml") as rf:
    d = load(rf)