Coverage for python/lsst/pipe/base/argumentParser.py: 85%

26 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2022-08-20 01:51 -0700

1# 

2# LSST Data Management System 

3# Copyright 2008-2015 AURA/LSST. 

4# 

5# This product includes software developed by the 

6# LSST Project (http://www.lsst.org/). 

7# 

8# This program is free software: you can redistribute it and/or modify 

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

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

11# (at your option) any later version. 

12# 

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

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

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

16# GNU General Public License for more details. 

17# 

18# You should have received a copy of the LSST License Statement and 

19# the GNU General Public License along with this program. If not, 

20# see <https://www.lsstcorp.org/LegalNotices/>. 

21# 

22__all__ = [ 

23 "ArgumentParser", 

24 "ConfigFileAction", 

25 "ConfigValueAction", 

26 "DataIdContainer", 

27 "DatasetArgument", 

28 "ConfigDatasetType", 

29 "InputOnlyArgumentParser", 

30] 

31 

32import argparse 

33 

34from deprecated.sphinx import deprecated 

35 

36 

37@deprecated( 

38 reason="Gen2 DataIdContainer is no longer supported. This functionality has been disabled.", 

39 version="v23.0", 

40 category=FutureWarning, 

41) 

42class DataIdContainer: 

43 """Container for data IDs and associated data references. 

44 

45 Parameters 

46 ---------- 

47 level : `str` 

48 The lowest hierarchy level to descend to for this dataset type, 

49 for example `"amp"` for `"raw"` or `"ccd"` for `"calexp"`. 

50 Use `""` to use the mapper's default for the dataset type. 

51 This class does not support `None`, but if it did, `None` 

52 would mean the level should not be restricted. 

53 

54 Notes 

55 ----- 

56 Override this class for data IDs that require special handling to be 

57 converted to ``data references``, and specify the override class 

58 as ``ContainerClass`` for ``add_id_argument``. 

59 

60 If you don't want the argument parser to compute data references, 

61 specify ``doMakeDataRefList=False`` in ``add_id_argument``. 

62 """ 

63 

64 def __init__(self, level=None): 

65 pass 

66 

67 

68@deprecated( 

69 reason="Gen2 DatasetArgument is no longer supported. This functionality has been disabled.", 

70 version="v23.0", 

71 category=FutureWarning, 

72) 

73class DatasetArgument: 

74 """Dataset type specified by a command-line argument. 

75 

76 Parameters 

77 ---------- 

78 name : `str`, optional 

79 Name of command-line argument (including leading "--", 

80 if appropriate) whose value is the dataset type. 

81 If `None`, uses ``--idName_dstype`` where idName 

82 is the name of the data ID argument (e.g. "id"). 

83 help : `str`, optional 

84 Help string for the command-line argument. 

85 default : `object`, optional 

86 Default value. If `None`, then the command-line option is required. 

87 This argument isignored if the command-line argument is positional 

88 (name does not start with "-") because positional arguments do 

89 not support default values. 

90 """ 

91 

92 def __init__( 

93 self, 

94 name=None, 

95 help="dataset type to process from input data repository", 

96 default=None, 

97 ): 

98 pass 

99 

100 

101@deprecated( 

102 reason="Gen2 ConfigDatasetType is no longer supported. This functionality has been disabled.", 

103 version="v23.0", 

104 category=FutureWarning, 

105) 

106class ConfigDatasetType: 

107 """Dataset type specified by a config parameter. 

108 

109 Parameters 

110 ---------- 

111 name : `str` 

112 Name of config option whose value is the dataset type. 

113 """ 

114 

115 def __init__(self, name): 

116 pass 

117 

118 

119@deprecated( 

120 reason="Gen2 ArgumentParser is no longer supported. This functionality has been disabled.", 

121 version="v23.0", 

122 category=FutureWarning, 

123) 

124class ArgumentParser(argparse.ArgumentParser): 

125 """Argument parser for command-line tasks that is based on 

126 `argparse.ArgumentParser`. 

127 

128 Parameters 

129 ---------- 

130 name : `str` 

131 Name of top-level task; used to identify camera-specific override 

132 files. 

133 usage : `str`, optional 

134 Command-line usage signature. 

135 **kwargs 

136 Additional keyword arguments for `argparse.ArgumentParser`. 

137 

138 Notes 

139 ----- 

140 Users may wish to add additional arguments before calling `parse_args`. 

141 """ 

142 

143 def __init__(self, name, usage="%(prog)s input [options]", **kwargs): 

144 pass 

145 

146 

147class InputOnlyArgumentParser(ArgumentParser): 

148 """`ArgumentParser` for command-line tasks that don't write any output.""" 

149 

150 

151class ConfigValueAction(argparse.Action): 

152 """argparse action callback to override config parameters using 

153 name=value pairs from the command-line. 

154 """ 

155 

156 def __call__(self, parser, namespace, values, option_string): 

157 pass 

158 

159 

160class ConfigFileAction(argparse.Action): 

161 """argparse action to load config overrides from one or more files.""" 

162 

163 def __call__(self, parser, namespace, values, option_string=None): 

164 """Load one or more files of config overrides. 

165 

166 Parameters 

167 ---------- 

168 parser : `argparse.ArgumentParser` 

169 Argument parser. 

170 namespace : `argparse.Namespace` 

171 Parsed command. The following attributes are updated by this 

172 method: ``namespace.config``. 

173 values : `list` 

174 A list of data config file paths. 

175 option_string : `str`, optional 

176 Option value specified by the user. 

177 """ 

178 pass