Coverage for python/lsst/daf/butler/cli/opt/optionGroups.py: 92%

18 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-08-05 01:25 +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 program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <http://www.gnu.org/licenses/>. 

21 

22 

23__all__ = ("query_datasets_options",) 

24 

25 

26import click 

27 

28from ..utils import OptionGroup, unwrap, where_help 

29from .arguments import glob_argument, repo_argument 

30from .options import collections_option, dataset_type_option, where_option 

31 

32 

33class query_datasets_options(OptionGroup): # noqa: N801 

34 """A collection of options common to querying datasets.""" 

35 

36 def __init__(self, repo: bool = True, showUri: bool = True, useArguments: bool = True) -> None: 

37 self.decorators = [] 

38 if repo: 

39 if not useArguments: 39 ↛ 40line 39 didn't jump to line 40, because the condition on line 39 was never true

40 raise RuntimeError("repo as an option is not currently supported.") 

41 self.decorators.append(repo_argument(required=True)) 

42 if useArguments: 

43 self.decorators.append( 

44 glob_argument( 

45 help=unwrap( 

46 """GLOB is one or more glob-style expressions that fully or partially identify the 

47 dataset type names to be queried.""" 

48 ) 

49 ) 

50 ) 

51 else: 

52 self.decorators.append( 

53 dataset_type_option( 

54 help=unwrap( 

55 """One or more glob-style expressions that fully or partially identify the dataset 

56 type names to be queried.""" 

57 ) 

58 ) 

59 ) 

60 self.decorators.extend( 

61 [ 

62 collections_option(), 

63 where_option(help=where_help), 

64 click.option( 

65 "--find-first", 

66 is_flag=True, 

67 help=unwrap( 

68 """For each result data ID, only yield one DatasetRef of each 

69 DatasetType, from the first collection in which a dataset of that dataset 

70 type appears (according to the order of 'collections' passed in). If 

71 used, 'collections' must specify at least one expression and must not 

72 contain wildcards.""" 

73 ), 

74 ), 

75 ] 

76 ) 

77 if showUri: 

78 self.decorators.append( 

79 click.option("--show-uri", is_flag=True, help="Show the dataset URI in results.") 

80 )