Questions tagged [ruamel.yaml]
ruamel.yaml is a YAML 1.2 loader/dumper library for Python, with round-trip preservation of comments, tags and flow style. It is a superset of the PyYAML package. Use this tag for issues with features or installation of that are ruamel.yaml specific.
ruamel.yaml
496
questions
1
vote
1
answer
33
views
How do I change DEFAULT quote of a string in pyyaml.ruamel.yaml
There are a lot of questions on stack overflow about how to preserve quotes in YAML, but there seem to be no questions asking how to merely change the default (from a single quote to a double quote) ...
0
votes
2
answers
45
views
Lose quotes around date when writing to YAML file
I have this script:
import json
from datetime import datetime, timedelta
import os
import ruamel.yaml
vulnerabilities = {}
expiration_date = (datetime.now() + timedelta(days=29)).strftime('%Y-%m-%d')
...
0
votes
0
answers
20
views
Usage of add_constructor() in 0.18.x
One of my packages (tinject), currently using ruamel.yaml 0.17.x, installs a custom constructor to implement a !include directive allowing me to write a document like:
foo:
- bar: 42
---
bar:
- ...
-1
votes
1
answer
52
views
python yaml formatting - preserving new lines and indentation
I'm trying to read a structured YAML file and write it back out to another file after updating some entries (both keys and values may be modified).
However, I specifically want to maintain the ...
1
vote
0
answers
18
views
Keep comments in ruamel.yaml square bracket lists
If I have said yaml file:
org-lists:
ea-orgs: [
1, # test-org
]
ga-orgs: [
2, # customer-2
3, # customer-3
4, # customer-4
]
It completely removes the comments after I do a ...
0
votes
0
answers
33
views
ruamel.yaml: use double quotes in YAML created with `YAML.dump()`
It seems there is a preserve_quotes attribute which can be used when working with an already ruamel.yaml-parsed YAML file.
However, what I have is a Python dictionary (to be precise, I have a pydantic ...
0
votes
1
answer
35
views
ruamel.yaml parser error when using Pyflink over Docker
I'm trying to run a flink job that consumes and provides data from/to a kafka source.In order to submit the job, I'm using the pyflink library.
I'm using:
Python 3.8.0
Flink 1.19.0
The docker file for ...
0
votes
0
answers
11
views
Resetting values containing comments in new line to empty list also modifies other values. Reloading resulting yaml errors
This is the yaml file I am loading
key1:
# comment1
- t1: t_value
u1: u_value
- t2: t_value
u2: u_value
key2:
# comment2
key21:
k1: 0.1
k2: 0.2
k3: 0.6
I am running the ...
-1
votes
1
answer
20
views
How can I delete single quotes using ruamel.yaml.dump
I wanted to make a yaml file from a python dict. But when I convert a regex string, the single quotes appears.
I want:
quickSearch:
type: string
maxLength: 250
pattern: [a-zA-...
-1
votes
1
answer
74
views
How can I prevent a negative floating number to be automatically changed in ruamel.yaml
I read a yaml-file with couple of floating numbers:
neg_number: -2.32870E+00
pos_number: 0.14618E+01
If I dump these numbers I get:
neg_number: -0.23287E+01
pos_number: 0.14618E+01
There is no ...
1
vote
1
answer
39
views
ruamel.yaml dump: how to stop map scalar values from being moved to a new indented line?
Hard to describe succinctly, so I'll demonstrate.
from sys import stdout
from ruamel.yaml import YAML
yml = YAML()
doc = """
kind: ImageSetConfiguration
apiVersion: mirror.openshift.io/...
0
votes
0
answers
23
views
Dump empty line with proper formatting in ruamel.yaml
I have a dict
{"a": ""}
and when I dump it in ruamel.yaml it appears like this:
a: ''
I tried dumping
{"a": None}
instead and got
a:<no space>
How can I get
a:&...
1
vote
2
answers
123
views
Preserve line wrapping in ruamel.yaml
Is there a way to preserve line wrapping with ruamel.yaml? The closest I have found is to use the width property but that doesn't quite do it.
Prevent long lines getting wrapped in ruamel.yaml
My use ...
0
votes
1
answer
48
views
How to get ruamel yaml to indent nested sequences with 2 spaces
We are using ruamel.yaml (0.18.6), and want to indent sequences with two leading spaces. we noticed that it uses a 2-space indent on the first sequence, but switches to a 4-space indent on the second ...
1
vote
1
answer
94
views
RUAMEL/PYYAML writting new lines to yaml
I have a large yaml configuration file I am editing. This is the ideal format.
...
- name: apple
Formula: |-
x = 3 + 4;
apple = x * 3 + y;
Inputs:
- y
- name: banana
Formula: |-
x =...