YAML file inheritance with nested string replacement fields and conditional formatting.
Project description
See https://github.com/CodeOptimist/rimworld-mod-description-tool for example inheritance.
---
fruit1: &fruit1
- name: 'Strawberry'
- name: 'Apple'
- name: 'Banana'
fruit1_names: &fruit1_names !each [ *fruit1, 'name' ]
fruit1_names_joined: !join [ ", ", *fruit1_names ]
fruit1_names_sliced: !each [ *fruit1, 'name', '{l|_,3}' ]
fruit2: &fruit2
- property: &strawberry { common: 'Strawberry', scientific: 'Fragaria × ananassa' }
- property: { common: 'Apple', scientific: 'Malus domestica' }
- property: { common: 'Banana', scientific: 'Musa acuminata' }
fruit2_property: !each [ *fruit2, 'property' ]
fruit2_scientific_joined: !join [ ", ", !each [ *fruit2, 'property.scientific' ] ]
fruit3: &fruit3 !insert
- [ *fruit1 ]
- name: 'Pineapple'
fruit3_names: !each [ *fruit3, 'name' ]
has_dog: ~
dog: 'a dog named "[BRACKY]"'
has_cat: Yup
cat: 'a cat named "{{CURLY}}"'
matrix: &matrix !concat
- [ 1, 2, 3 ]
- [ 4, 5, 6 ]
- [ 7, 8, 9 ]
float_matrix: !each [ *matrix, ~, '{l:.3f}' ]
fruit4: !merge
<: *strawberry
color: 'red'
# [text to format, expected literal result]
tests:
- [ '{fruit1_names}', "['Strawberry', 'Apple', 'Banana']" ]
- [ '{fruit1_names_joined}', 'Strawberry, Apple, Banana' ]
- [ '{fruit1_names_sliced}', "['Str', 'App', 'Ban']" ]
- [ '{fruit2_scientific_joined}', 'Fragaria × ananassa, Malus domestica, Musa acuminata' ]
- [ '{fruit3_names}', "['Strawberry', 'Apple', 'Banana', 'Pineapple']" ]
- [ '{dog}', 'a dog named "[BRACKY]"' ]
- [ '{has_dog?={{dog}} is {dog}}', '' ]
- [ '{cat}', 'a cat named "{CURLY}"' ]
- [ '{has_cat?={{cat}} is {cat}}', '{cat} is a cat named "{CURLY}"' ]
- [ '{has_cat?+ sure do.}', 'Yup sure do.' ]
- [ '{optional?}', '' ]
- [ '{matrix}', '[1, 2, 3, 4, 5, 6, 7, 8, 9]' ]
- [ '{fruit4!e}', "{'common': 'Strawberry', 'scientific': 'Fragaria × ananassa', 'color': 'red'}" ]
- [ '{float_matrix}', "['1.000', '2.000', '3.000', '4.000', '5.000', '6.000', '7.000', '8.000', '9.000']" ]
- [ '{fruit1.name^Apple!e}', "{'name': 'Apple'}" ]
- [ '{fruit2_property.common^Banana!e}', "{'common': 'Banana', 'scientific': 'Musa acuminata'}" ]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
codeoptimist.yaml-0.2.0.tar.gz
(18.1 kB
view details)
Built Distribution
File details
Details for the file codeoptimist.yaml-0.2.0.tar.gz
.
File metadata
- Download URL: codeoptimist.yaml-0.2.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc81041ad8ff3a6278805d147801a1ebd6dd17f57eda3a60a331fe07afc8bf21 |
|
MD5 | 7e2c69b9873b77b89e1aceac825f786e |
|
BLAKE2b-256 | 1cc73e8730f7dfe2e82122e65e980f8094c5d6ad815f46483460ba0321c8756c |
File details
Details for the file codeoptimist.yaml-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: codeoptimist.yaml-0.2.0-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fd9a3e6639be2167c06fae6bf6b42e944681ec6f36d3ffcbc5f6abaadb72a32 |
|
MD5 | c2637627b743cd3d09f123326377924b |
|
BLAKE2b-256 | 79b222277c8b69cc0d33b9ea21dc27ded0b451a7241e36230a5fb4c6450d7a1c |