Skip to main content

title: yglu ReadMe

Yglu ᕄ !?

Build Status PyPI version

* Try Yglu Online *

Yglu is YAML augmented with an advanced expression language. Unlike usual text templating, Yglu relies on the YAML structure and leverages its tag system combined with the YAQL query language.

This association enables templating and functional processing a bit like if YAML nodes were spreadsheet cells.

Yglu input documents are pure and valid YAML using tags for computed nodes.

input
a: 1
b: !? .a + 1
!if .b = 2:
  c: 3  
output
a: 1
b: 2
c: 3
 
input
names: !-
  - 'nginx:1.16'
  - 'node:13.6'
  - 'couchbase:9.3'
image: !()
  !? $.split(':')[0]:
    version: !? $.split(':')[1]
images: !?
  $_.names
    .select(($_.image)($))
    .aggregate($1.mergeWith($2), {})
output
images:
  nginx:
    version: '1.16'
  node:
    version: '13.6'
  couchbase:
    version: '9.3'
     
     
     
       

In the example above, the names sequence is hidden, image is a function (like a template block) and images is an expression which iterates through all names, applies the image function to each one and aggregates the individual results by merging them together as a mapping.

As such an operation is often needed, Yglu provides a !for tag for merging a sequence iterated over a function:

input
names: !-
  - 'nginx:1.16'
  - 'node:13.6'
  - 'couchbase:9.3'
images:
  !for .names: !()
    !? $.split(':')[0]:
      version: !? $.split(':')[1]
output
images:
  nginx:
    version: '1.16'
  node:
    version: '13.6'
  couchbase:
    version: '9.3'
     

See the test samples for more examples.

* Try Yglu Online *

Install

pip3 install yglu

Run

Usage: yglu [options] [<filename>]

Options:
  -v - -version          Print version and exit.
  -h - -help             Print help and exit.

Tags

Tags specify an alteration of the document structure.

Tag    Description
!? Evaluate an expression. The result can be a scalar, mapping or sequence. Can also be used in mapping keys.
!- Hide the node in the output but keep it accessible from expressions. Can be an expression.
!() Make the node reusable in expressions as a function.
!if Conditional merge. See if.yml.
!for Merge the results of a function applied to all items of a sequence . See for.yml.
!apply Apply a function or function block to a block. See function.yml.

Expressions

Expressions are written in YAQL.

They are evaluated in a context with the following variables defined:

Variable Description
$_ Refers to the current document root. Can be omitted at the beginning of the expression if it starts with a dot.
$ Implicit argument of functions.
$env Gives access to environment variables. Disabled by default. Set the $YGLU_ENABLE_ENV environment variable to enable this feature.
$this Refers to the current function block node in order to access its children nodes. See function.yml

Built-in Functions

In addition to the standard YAQL library, Yglu defines the following functions:

Function Description
$import(filename) Imports another document in the current node. By default, it is only permitted to import files from within the directory hierarchy of the input file. Set $YGLU_IMPORT_ALLOW to a list of permitted directories.

Metadata

Release files for yglu 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yglu 1.1.2
File Size Uploaded Provenance Actions
yglu-1.1.2.tar.gz 22.9 kB Without provenance Details for yglu-1.1.2.tar.gz

Release files / yglu-1.1.2.tar.gz

Download URL yglu-1.1.2.tar.gz
Size 22.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3301f852987c675ed25382a22e7ebc21e7f9b54e0e54d52067108505581b3346
BLAKE2b-256 checksum
How to use checksums
01d20678ba02aa7ac186939e2dba21b0ab8cddea2c4870a75084e71fa5e9d689
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.10

Security for yglu 1.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page