https://github.com/podhmo/zenmai
toylang on yaml or json
https://github.com/podhmo/zenmai
json minilang toylang yaml
Last synced: 2 months ago
JSON representation
toylang on yaml or json
- Host: GitHub
- URL: https://github.com/podhmo/zenmai
- Owner: podhmo
- License: mit
- Created: 2017-04-15T08:41:58.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-13T09:05:23.000Z (about 9 years ago)
- Last Synced: 2025-11-29T07:19:31.637Z (7 months ago)
- Topics: json, minilang, toylang, yaml
- Language: Python
- Size: 77.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.txt
- License: LICENSE
Awesome Lists containing this project
README
zenmai
========================================
.. image:: https://travis-ci.org/podhmo/zenmai.svg?branch=master
:target: https://travis-ci.org/podhmo/zenmai
toylang on yaml or json
command line example
----------------------------------------
main.yaml
.. code-block:: 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
.. code-block:: yaml
definitions:
nums0:
type: integer
enum:
[1, 2, 3, 4, 5, 6]
nums1:
type: integer
enum:
[1, 2, 3, 5, 7, 11]
filters.py
.. code-block:: python
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.
.. code-block:: bash
$ zenmai examples/readme2/main.yaml
output
.. code-block:: yaml
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.
.. code-block:: python
from zenma.loader import load
with open("config.yaml") as rf:
d = load(rf)