-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed library for YAML so comments are preserved
- Introduced ruamel.yaml
- Loading branch information
Showing
5 changed files
with
991 additions
and
1,287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
import yaml | ||
from ruamel.yaml import YAML | ||
from cli.helpers.objdict_helpers import objdict_to_dict, dict_to_objdict | ||
|
||
|
||
def safe_load_all(stream): | ||
docs = list(yaml.safe_load_all(stream)) | ||
yaml = YAML() | ||
yaml.default_flow_style = False | ||
docs = list(yaml.load_all(stream)) | ||
conv_docs = [] | ||
for doc in docs: | ||
conv_docs.append(dict_to_objdict(doc)) | ||
return conv_docs | ||
|
||
|
||
def safe_load(stream): | ||
doc = yaml.safe_load(stream) | ||
yaml = YAML() | ||
yaml.default_flow_style = False | ||
doc = yaml.load(stream) | ||
return dict_to_objdict(doc) | ||
|
||
|
||
def dump_all(docs, stream): | ||
yaml = YAML() | ||
yaml.default_flow_style = False | ||
doc2 = docs | ||
conv_docs = [] | ||
for doc in doc2: | ||
conv_docs.append(objdict_to_dict(doc)) | ||
yaml.dump_all(conv_docs, stream, default_flow_style=False) | ||
yaml.dump_all(conv_docs, stream) | ||
|
||
|
||
def dump(doc, stream): | ||
yaml.dump(objdict_to_dict(doc), stream, default_flow_style=False) | ||
yaml = YAML() | ||
yaml.default_flow_style = False | ||
yaml.dump(objdict_to_dict(doc), stream) | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters