mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
disable YAML aliases
This commit is contained in:
@ -253,17 +253,22 @@ def yaml_out(data, pretty=False, env_colors=None, mono=False, piped_out=False, a
|
|||||||
warning message to STDERR"""
|
warning message to STDERR"""
|
||||||
# make ruamel.yaml import optional
|
# make ruamel.yaml import optional
|
||||||
try:
|
try:
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML, representer
|
||||||
YAML_INSTALLED = True
|
YAML_INSTALLED = True
|
||||||
except Exception:
|
except Exception:
|
||||||
YAML_INSTALLED = False
|
YAML_INSTALLED = False
|
||||||
|
|
||||||
if YAML_INSTALLED:
|
if YAML_INSTALLED:
|
||||||
y_string_buf = io.BytesIO()
|
y_string_buf = io.BytesIO()
|
||||||
|
|
||||||
# monkey patch to disable plugins since we don't use them and in
|
# monkey patch to disable plugins since we don't use them and in
|
||||||
# ruamel.yaml versions prior to 0.17.0 the use of __file__ in the
|
# ruamel.yaml versions prior to 0.17.0 the use of __file__ in the
|
||||||
# plugin code is incompatible with the pyoxidizer packager
|
# plugin code is incompatible with the pyoxidizer packager
|
||||||
YAML.official_plug_ins = lambda a: []
|
YAML.official_plug_ins = lambda a: []
|
||||||
|
|
||||||
|
# monkey patch to disable aliases
|
||||||
|
representer.RoundTripRepresenter.ignore_aliases = lambda x, y: True
|
||||||
|
|
||||||
yaml = YAML()
|
yaml = YAML()
|
||||||
yaml.default_flow_style = False
|
yaml.default_flow_style = False
|
||||||
yaml.explicit_start = True
|
yaml.explicit_start = True
|
||||||
|
Reference in New Issue
Block a user