summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Kislyuk <kislyuk@gmail.com>2021-11-28 21:29:43 -0800
committerAndrey Kislyuk <kislyuk@gmail.com>2021-11-28 21:29:43 -0800
commit32dd888eb6e20a673b65ba3391c4225c24c8f585 (patch)
tree4afbc6e7fcfd98337d9e44e12961532c5ab335f6
parentf4acc79dafcad7c63f9de7a9f70766886f4a11cc (diff)
Wire up expand_aliasesdisable-anchors
-rwxr-xr-xyq/__init__.py7
-rw-r--r--yq/parser.py1
2 files changed, 5 insertions, 3 deletions
diff --git a/yq/__init__.py b/yq/__init__.py
index 37e3ba9..39f27f7 100755
--- a/yq/__init__.py
+++ b/yq/__init__.py
@@ -155,7 +155,8 @@ def load_yaml_docs(in_stream, out_stream, jq, loader_class, max_expansion_factor
def yq(input_streams=None, output_stream=None, input_format="yaml", output_format="json",
program_name="yq", width=None, indentless_lists=False, xml_root=None, xml_dtd=False, xml_force_list=frozenset(),
- explicit_start=False, explicit_end=False, max_expansion_factor=1024, jq_args=frozenset(), exit_func=None):
+ explicit_start=False, explicit_end=False, expand_aliases=True, max_expansion_factor=1024, jq_args=frozenset(),
+ exit_func=None):
if not input_streams:
input_streams = [sys.stdin]
if not output_stream:
@@ -185,7 +186,7 @@ def yq(input_streams=None, output_stream=None, input_format="yaml", output_forma
json_buffer = io.StringIO()
for input_stream in input_streams:
if input_format == "yaml":
- loader_class = get_loader(use_annotations=use_annotations)
+ loader_class = get_loader(use_annotations=use_annotations, expand_aliases=expand_aliases)
load_yaml_docs(in_stream=input_stream, out_stream=json_buffer, jq=None, loader_class=loader_class,
max_expansion_factor=max_expansion_factor, exit_func=exit_func, prog=program_name)
elif input_format == "xml":
@@ -235,7 +236,7 @@ def yq(input_streams=None, output_stream=None, input_format="yaml", output_forma
toml.dump(doc, output_stream)
else:
if input_format == "yaml":
- loader_class = get_loader(use_annotations=False)
+ loader_class = get_loader(use_annotations=False, expand_aliases=expand_aliases)
for input_stream in input_streams:
load_yaml_docs(in_stream=input_stream, out_stream=jq.stdin, jq=jq, loader_class=loader_class,
max_expansion_factor=max_expansion_factor, exit_func=exit_func, prog=program_name)
diff --git a/yq/parser.py b/yq/parser.py
index abc9550..df7ba20 100644
--- a/yq/parser.py
+++ b/yq/parser.py
@@ -63,6 +63,7 @@ def get_parser(program_name, description):
parser.add_argument("--indentless-lists", "--indentless", action="store_true", help=indentless_help)
parser.add_argument("--explicit-start", action="store_true", help=argparse.SUPPRESS)
parser.add_argument("--explicit-end", action="store_true", help=argparse.SUPPRESS)
+ parser.add_argument("--no-expand-aliases", action="store_false", dest="expand_aliases", help=argparse.SUPPRESS)
parser.add_argument("--max-expansion-factor", type=int, default=1024, help=argparse.SUPPRESS)
parser.add_argument("--xml-output", "-x", dest="output_format", action="store_const", const="xml",
help=xml_output_help)