Skip to content
Snippets Groups Projects
Commit cfc1290e authored by Yannis Barlas's avatar Yannis Barlas
Browse files

demo

parents
Branches main
No related tags found
No related merge requests found
myenv
services:
client:
image: original-client
otherField: 1
server:
image: original-server
otherField: 2
\ No newline at end of file
services:
client:
image: custom-client
otherField: 1
server:
image: original-server
otherField: 2
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
in.yml 0 → 100644
services:
client:
image: original-client
otherField: 1
server:
image: original-server
otherField: 2
\ No newline at end of file
%% Cell type:code id:4fc7132f-85e5-4080-a057-2fed296fb621 tags:
``` python
import yaml
```
%% Cell type:code id:d67f71af-63d6-451e-bd99-a75615022dbc tags:
``` python
with open('in.yml', 'r') as file:
data = yaml.safe_load(file)
# print('original client image: "', data['services']['client']['image'], '"')
data['services']['client']['image'] = 'custom-client'
# print('new client image: "', data['services']['client']['image'], '"')
with open('out.yml', 'w') as file:
yaml.dump(data, file, default_flow_style=False)
```
%% Cell type:code id:4692d95b-8280-4527-bca0-fcc98b518829 tags:
``` python
with open('out.yml', 'r') as file:
data = yaml.safe_load(file)
print('data from output file', data)
```
%% Output
data from output file {'services': {'client': {'image': 'custom-client', 'otherField': 1}, 'server': {'image': 'original-server', 'otherField': 2}}}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment