Questions tagged [pyyaml]

PyYAML is a YAML 1.1 parser and emitter for Python. Use this tag for PyYAML specific python questions.

PyYAML is a parser/dumper for YAML 1.1 for the Python programming language.

PyYAML does not yet implemented the feature changes from the YAML 1.2 specification released in 2009.

See http://pyyaml.org/wiki/PyYAML for background and documentation.

Source code: https://github.com/yaml/pyyaml

828 questions
-1
votes
1 answer

Getting specific values from a JSON file and put it through to specific fields in an existing YAML file

This is the JSON file, vip5.json. { "App Name": "test", "Email": "test@test.com", "Employee ID": "abc", "Load Balancing Method": "Ratio", "Network": "CMN", "Pool Member": "pucq", "Pool Monitor": "tcp", "Pool name": "pool", "SSL":…
Bharath
  • 559
  • 11
  • 27
-1
votes
1 answer

Can Ansible dictionaries refer to themselves?

I'm trying to build certain software on each machine locally. The playbook would download the source tarball (using get_url), configure and build it. I'd like to define the list of items to build as something like the below: srcpkg: python: …
Mikhail T.
  • 3,043
  • 3
  • 29
  • 46
-1
votes
1 answer

Dicts become OrderedDicts with yaml files

I'm trying to write something into a .yaml file but am confused by the documentation. It there says the following: Block mapping can be nested: # YAML hero: hp: 34 sp: 8 level: 4 orc: hp: 12 sp: 0 level: 2 # Python {'hero': {'hp': 34,…
Lithimlin
  • 542
  • 1
  • 6
  • 24
-1
votes
1 answer

Access python dict value in yaml with tags

Is it possible to load the value from a python dict in yaml? I can access variable by using: !!python/name:mymodule.myfile.myvar but this give the whole dict. Trying to use dict get method like so: test: &TEST…
bboumend
  • 490
  • 3
  • 13
-1
votes
1 answer

Yii2: update field Error Unknown column with query builder

I have database table 'cat_ralation' CREATE TABLE IF NOT EXISTS `cat_relation` ( `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, `cat_id` int(11) NOT NULL, `obj_id` int(11) NOT NULL, `obj_type` varchar(20) NOT NULL ) ENGINE=InnoDB DEFAULT…
luongit
  • 117
  • 2
  • 13
-1
votes
1 answer

How to add a bracket {} under one tag in yaml file by Python?

I want to make one YAML file by Python like as below. A: B: c: {d:e} but if I do it like as below: data = {'A':{'B':{ 'c':'{d:e}'}}} yaml.dump(data,file,default_flow_style = False) the output in the file is as below: A: B: c: '{d:…
subhadip
  • 39
  • 5
-1
votes
1 answer

Dumping Collection to YAML file with PyYaml

I am writing a python application. I am trying to dump my python object into yaml using PyYaml. I am using Python 2.6 and running Ubuntu Lucid 10.04. I am using the PyYAML package in Ubuntu Package:…
zfranciscus
  • 16,175
  • 10
  • 47
  • 53
-1
votes
2 answers

How access element at an index of generator in python?

I am new to python & facing issue while accessing second element of iterateable returned by function from lib pyyaml, yaml.load_all, below is code: import os import yaml file = "abc.yaml" stream = open(file) docs = yaml.load_all(stream) print…
Shashank
  • 416
  • 5
  • 16
-1
votes
1 answer

PyYAML add string to list

I'm pretty new to PyYAML and don't understand everything about it. I have a YAML file with a list; the-list: - "string1" - "string2" - "string3" I have managed to find out how to fetch the list in my python file, but not how to add another…
user3264073
  • 21
  • 2
  • 4
-2
votes
1 answer

New to Python. Which version of PyYAML do I need to install in my Python Azure runbook?

I have a basic Python script that I'm executing in an Python Azure Runbook. I need to install the PyYAML package but I don't know how to do it. I have installed other packages ok as when I download from PyPI they come with the name format…
-2
votes
2 answers

How do I check if a key exists in a yaml file Python

I'm trying to check if a username exists in a yaml file the format of my file goes as: random_uuid: username: "" random_uuid: username: "" random_uuid: username: "" I'm still unsure how to do it after googling as it must look through…
Sam Walker
  • 11
  • 1
  • 2
-2
votes
1 answer

Convert incorrectly indented YAML file to python dictionary

There is a yaml file which is having wrong indentation like below: name: testing date: 2020-07-13 version: 1.0 targets: - sequence: 1 name: Book1 author: abc - sequence: 2 name: Book2 author: xyz which If I…
Girish
  • 366
  • 3
  • 15
-2
votes
1 answer

Pyyaml, accessing dictionary in Python

I have some yaml I'm trying to access keys in python. --- nodes: - AAAA: AAAA BBBB: BBBB CCCC: CCCC DDDD: AAAA: AAAA BBBB: AAAA CCCC: CCCC - AAAA: AAAA BBBB: BBBB CCCC: CCCC DDDD: AAAA: AAAA BBBB: AAAA CCCC:…
Neil Bernard
  • 131
  • 2
  • 9
-2
votes
1 answer

Changing DictMixin.iterkeys to MutableMapping

I'm looking to use OrderedDict in my code since the Ruby version of this project uses YAML for maps and settings but OrderedDict hasn't been updated for Python 3. The Ruby version of the project uses this file:…
bricky149
  • 81
  • 1
  • 1
  • 8
-3
votes
1 answer

I installed pyyaml via pip, but when I run my Python3 script, I'm not it can't find the module

I’m on Mac OS X Big Sur. I installed python3 via brew, and have this version $ python3 --version Python 3.9.13 Pip verison is $ pip3 --version pip 22.1.1 from /Users/davea/Library/Python/3.8/lib/python/site-packages/pip (python 3.8) I want to…
Dave
  • 15,639
  • 133
  • 442
  • 830
1 2 3
55
56