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

18 statements  

« prev     ^ index     » next       coverage.py v7.2.5, created at 2023-05-18 09:12 +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 def __init__(self, repo: bool = True, showUri: bool = True, useArguments: bool = True) -> None: 

35 self.decorators = [] 

36 if repo: 

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

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

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

40 if useArguments: 

41 self.decorators.append( 

42 glob_argument( 

43 help=unwrap( 

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

45 dataset type names to be queried.""" 

46 ) 

47 ) 

48 ) 

49 else: 

50 self.decorators.append( 

51 dataset_type_option( 

52 help=unwrap( 

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

54 type names to be queried.""" 

55 ) 

56 ) 

57 ) 

58 self.decorators.extend( 

59 [ 

60 collections_option(), 

61 where_option(help=where_help), 

62 click.option( 

63 "--find-first", 

64 is_flag=True, 

65 help=unwrap( 

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

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

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

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

70 contain wildcards.""" 

71 ), 

72 ), 

73 ] 

74 ) 

75 if showUri: 

76 self.decorators.append( 

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

78 )