Coverage for python/lsst/images/cli/_minify.py: 59%

15 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-06-10 16:39 +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 

12 

13__all__ = ("minify",) 

14 

15import os 

16 

17import click 

18 

19 

20@click.command(name="minify") 

21@click.argument("input", type=click.Path(exists=True, dir_okay=False)) 

22@click.argument("output", type=click.Path(dir_okay=False)) 

23@click.option("--schema-name", default=None, help="Top-level schema name; auto-detected if omitted.") 

24@click.option("--overwrite", is_flag=True, default=False, help="Overwrite OUTPUT if it exists.") 

25def minify(input: str, output: str, schema_name: str | None, overwrite: bool) -> None: 

26 """Subset a real archive into a small JSON test fixture.""" 

27 from ..tests._minify_for_fixtures import minify as _minify 

28 

29 if os.path.exists(output) and not overwrite: 

30 raise click.ClickException(f"{output!r} already exists; pass --overwrite to replace it.") 

31 _minify(input, output, schema_name=schema_name) 

32 click.echo(f"Wrote {output}.")