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

14 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-06-25 01:29 -0700

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("--overwrite", is_flag=True, default=False, help="Overwrite OUTPUT if it exists.") 

24def minify(input: str, output: str, overwrite: bool) -> None: 

25 """Subset a real data file into a small test fixture.""" 

26 from ..tests._minify_for_fixtures import minify as _minify 

27 

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

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

30 _minify(input, output) 

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