From 96925013e65d0ce9986b9c785296b21bfe760ea8 Mon Sep 17 00:00:00 2001 From: Brett Date: Wed, 18 Dec 2024 09:11:26 -0500 Subject: [PATCH] reducing some redundancy --- asdf/_convenience.py | 11 +++++------ asdf/commands/info.py | 5 +++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/asdf/_convenience.py b/asdf/_convenience.py index a0f57dbfd..a147bb333 100644 --- a/asdf/_convenience.py +++ b/asdf/_convenience.py @@ -7,7 +7,7 @@ from contextlib import contextmanager from ._asdf import AsdfFile, open_asdf -from ._display import DEFAULT_MAX_COLS, DEFAULT_MAX_ROWS, DEFAULT_SHOW_VALUES, render_tree +from ._display import DEFAULT_MAX_COLS, DEFAULT_MAX_ROWS, DEFAULT_SHOW_VALUES __all__ = ["info"] @@ -41,18 +41,17 @@ def info(node_or_path, max_rows=DEFAULT_MAX_ROWS, max_cols=DEFAULT_MAX_COLS, sho the rendered tree. """ with _manage_node(node_or_path) as node: - lines = render_tree(node, max_rows=max_rows, max_cols=max_cols, show_values=show_values, identifier="root") - print("\n".join(lines)) + node.info(max_rows=max_rows, max_cols=max_cols, show_values=show_values) @contextmanager def _manage_node(node_or_path): if isinstance(node_or_path, (str, pathlib.Path)): with open_asdf(node_or_path) as af: - yield af.tree + yield af elif isinstance(node_or_path, AsdfFile): - yield node_or_path.tree + yield node_or_path else: - yield node_or_path + yield AsdfFile(node_or_path) diff --git a/asdf/commands/info.py b/asdf/commands/info.py index 7e8a5f076..9ca898b2c 100644 --- a/asdf/commands/info.py +++ b/asdf/commands/info.py @@ -2,7 +2,7 @@ Commands for displaying summaries of ASDF trees """ -from asdf import _convenience as convenience +import asdf from .main import Command @@ -36,4 +36,5 @@ def run(cls, args): def info(filename, max_rows, max_cols, show_values): - convenience.info(filename, max_rows=max_rows, max_cols=max_cols, show_values=show_values) + with asdf.open(filename) as af: + af.info(max_rows, max_cols, show_values)