Coverage for python/lsst/daf/butler/cli/opt/optionGroups.py: 92%
18 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-01 10:59 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-01 10:59 +0000
1# This file is part of ctrl_mpexec.
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# This software is dual licensed under the GNU General Public License and also
10# under a 3-clause BSD license. Recipients may choose which of these licenses
11# to use; please see the files gpl-3.0.txt and/or bsd_license.txt,
12# respectively. If you choose the GPL option then the following text applies
13# (but note that there is still no warranty even if you opt for BSD instead):
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU General Public License as published by
17# the Free Software Foundation, either version 3 of the License, or
18# (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
29__all__ = ("query_datasets_options",)
32import click
34from ..utils import OptionGroup, unwrap, where_help
35from .arguments import glob_argument, repo_argument
36from .options import collections_option, dataset_type_option, where_option
39class query_datasets_options(OptionGroup): # noqa: N801
40 """A collection of options common to querying datasets."""
42 def __init__(self, repo: bool = True, showUri: bool = True, useArguments: bool = True) -> None:
43 self.decorators = []
44 if repo:
45 if not useArguments: 45 ↛ 46line 45 didn't jump to line 46, because the condition on line 45 was never true
46 raise RuntimeError("repo as an option is not currently supported.")
47 self.decorators.append(repo_argument(required=True))
48 if useArguments:
49 self.decorators.append(
50 glob_argument(
51 help=unwrap(
52 """GLOB is one or more glob-style expressions that fully or partially identify the
53 dataset type names to be queried."""
54 )
55 )
56 )
57 else:
58 self.decorators.append(
59 dataset_type_option(
60 help=unwrap(
61 """One or more glob-style expressions that fully or partially identify the dataset
62 type names to be queried."""
63 )
64 )
65 )
66 self.decorators.extend(
67 [
68 collections_option(),
69 where_option(help=where_help),
70 click.option(
71 "--find-first",
72 is_flag=True,
73 help=unwrap(
74 """For each result data ID, only yield one DatasetRef of each
75 DatasetType, from the first collection in which a dataset of that dataset
76 type appears (according to the order of 'collections' passed in). If
77 used, 'collections' must specify at least one expression and must not
78 contain wildcards."""
79 ),
80 ),
81 ]
82 )
83 if showUri:
84 self.decorators.append(
85 click.option("--show-uri", is_flag=True, help="Show the dataset URI in results.")
86 )