Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildstream
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
BuildStream
buildstream
Commits
32ea8e4f
Commit
32ea8e4f
authored
7 years ago
by
Tristan Van Berkom
Browse files
Options
Downloads
Patches
Plain Diff
_yaml.py: Make _yaml.dump() optionally dump to stdout
parent
654dedb2
Branches
Branches containing commit
Tags
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildstream/_yaml.py
+8
-4
8 additions, 4 deletions
buildstream/_yaml.py
with
8 additions
and
4 deletions
buildstream/_yaml.py
+
8
−
4
View file @
32ea8e4f
...
...
@@ -18,9 +18,11 @@
# Authors:
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
import
sys
import
collections
import
copy
from
enum
import
Enum
from
contextlib
import
ExitStack
from
ruamel
import
yaml
from
ruamel.yaml.representer
import
SafeRepresenter
,
RoundTripRepresenter
...
...
@@ -227,10 +229,12 @@ def load(filename, shortname=None, copy_tree=False):
# node (dict): A node previously loaded with _yaml.load() above
# filename (str): The YAML file to load
#
#
def
dump
(
node
,
filename
):
with
open
(
filename
,
'
w
'
)
as
f
:
def
dump
(
node
,
filename
=
None
):
with
ExitStack
()
as
stack
:
if
filename
:
f
=
stack
.
enter_context
(
open
(
filename
,
'
w
'
))
else
:
f
=
sys
.
stdout
yaml
.
round_trip_dump
(
node
,
f
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment