Coverage for python/lsst/images/cli/_describe.py: 78%
16 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-30 08:38 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-30 08:38 +0000
1# This file is part of lsst-images.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# Use of this source code is governed by a 3-clause BSD-style
10# license that can be found in the LICENSE file.
11from __future__ import annotations
13__all__ = ("describe",)
15import click
16from rich.console import Console
18from ..describe import Describable
19from ..serialization import ArchiveReadError, read_archive
22@click.command(name="describe")
23@click.argument("file", type=click.Path(exists=True, dir_okay=False))
24def describe(file: str) -> None: # numpydoc ignore=PR01
25 """Deserialize an lsst.images file and print its data-model report.
27 Unlike ``inspect`` (which reports only the file layout), this reads the
28 full object and renders its `~lsst.images.Report` via the rich terminal
29 renderer, including nested components and, where available, WCS corner
30 sky coordinates.
31 """
32 try:
33 obj = read_archive(file)
34 except (ArchiveReadError, ValueError, TypeError) as err:
35 raise click.ClickException(f"Could not read {file}: {err}") from None
36 if not isinstance(obj, Describable): 36 ↛ 37line 36 didn't jump to line 37 because the condition on line 36 was never true
37 raise click.ClickException(f"{type(obj).__name__} does not support 'describe'.")
38 Console().print(obj.describe(detail=True))