Coverage for skema/gromet/fn/literal_value.py: 81%

115 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-04-30 17:15 +0000

1# coding: utf-8 

2 

3""" 

4 Grounded Model Exchange (GroMEt) schema for Function Networks 

5 

6 This document defines the GroMEt Function Network data model. Note that Metadata is defined in separate spec. __Using Swagger to Generate Class Structure__ To automatically generate Python or Java models corresponding to this document, you can use [swagger-codegen](https://swagger.io/tools/swagger-codegen/). This can be used to generate the client code based off of this spec, and in the process this will generate the data model class structure. 1. Install via the method described for your operating system [here](https://github.com/swagger-api/swagger-codegen#Prerequisites). Make sure to install a version after 3.0 that will support openapi 3. 2. Run swagger-codegen with the options in the example below. The URL references where the yaml for this documentation is stored on github. Make sure to replace CURRENT_VERSION with the correct version. (The current version is `0.1.7`.) To generate Java classes rather, change the `-l python` to `-l java`. Change the value to the `-o` option to the desired output location. ``` swagger-codegen generate -l python -o ./client -i https://raw.githubusercontent.com/ml4ai/automates-v2/master/docs/source/gromet_FN_v{CURRENT_VERSION}.yaml ``` 3. Once it executes, the client code will be generated at your specified location. For python, the classes will be located in `$OUTPUT_PATH/skema.gromet.fn.`. For java, they will be located in `$OUTPUT_PATH/src/main/java/io/swagger/client/model/` If generating GroMEt schema data model classes in SKEMA (AutoMATES), then after generating the above, follow the instructions here: ``` <automates>/automates/model_assembly/gromet/model/README.md ``` # noqa: E501 

7 

8 OpenAPI spec version: 0.1.10 

9 Contact: claytonm@arizona.edu 

10 Generated by: https://github.com/swagger-api/swagger-codegen.git 

11""" 

12 

13import pprint 

14import re # noqa: F401 

15 

16import six 

17 

18class LiteralValue(object): 

19 """NOTE: This class is auto generated by the swagger code generator program. 

20 

21 Do not edit the class manually. 

22 """ 

23 """ 

24 Attributes: 

25 swagger_types (dict): The key is attribute name 

26 and the value is attribute type. 

27 attribute_map (dict): The key is attribute name 

28 and the value is json key in definition. 

29 """ 

30 swagger_types = { 

31 'value_type': 'str', 

32 'value': 'object', 

33 'source_fn': 'int', 

34 'import_type': 'ImportType', 

35 'import_version': 'str', 

36 'import_source': 'TypedValue', 

37 'source_language': 'str', 

38 'source_language_version': 'str', 

39 'gromet_type': 'str' 

40 } 

41 

42 attribute_map = { 

43 'value_type': 'value_type', 

44 'value': 'value', 

45 'source_fn': 'source_fn', 

46 'import_type': 'import_type', 

47 'import_version': 'import_version', 

48 'import_source': 'import_source', 

49 'source_language': 'source_language', 

50 'source_language_version': 'source_language_version', 

51 'gromet_type': 'gromet_type' 

52 } 

53 

54 def __init__(self, value_type=None, value=None, source_fn=None, import_type=None, import_version=None, import_source=None, source_language=None, source_language_version=None, gromet_type='LiteralValue'): # noqa: E501 

55 """LiteralValue - a model defined in Swagger""" # noqa: E501 

56 self._value_type = None 

57 self._value = None 

58 self._source_fn = None 

59 self._import_type = None 

60 self._import_version = None 

61 self._import_source = None 

62 self._source_language = None 

63 self._source_language_version = None 

64 self._gromet_type = None 

65 self.discriminator = None 

66 if value_type is not None: 

67 self.value_type = value_type 

68 if value is not None: 

69 self.value = value 

70 if source_fn is not None: 

71 self.source_fn = source_fn 

72 if import_type is not None: 

73 self.import_type = import_type 

74 if import_version is not None: 

75 self.import_version = import_version 

76 if import_source is not None: 

77 self.import_source = import_source 

78 if source_language is not None: 

79 self.source_language = source_language 

80 if source_language_version is not None: 

81 self.source_language_version = source_language_version 

82 if gromet_type is not None: 

83 self.gromet_type = gromet_type 

84 

85 @property 

86 def value_type(self): 

87 """Gets the value_type of this LiteralValue. # noqa: E501 

88 

89 The type of the value. # noqa: E501 

90 

91 :return: The value_type of this LiteralValue. # noqa: E501 

92 :rtype: str 

93 """ 

94 return self._value_type 

95 

96 @value_type.setter 

97 def value_type(self, value_type): 

98 """Sets the value_type of this LiteralValue. 

99 

100 The type of the value. # noqa: E501 

101 

102 :param value_type: The value_type of this LiteralValue. # noqa: E501 

103 :type: str 

104 """ 

105 

106 self._value_type = value_type 

107 

108 @property 

109 def value(self): 

110 """Gets the value of this LiteralValue. # noqa: E501 

111 

112 The value as an object representing the value. Interpret the value object according to the value_type. # noqa: E501 

113 

114 :return: The value of this LiteralValue. # noqa: E501 

115 :rtype: object 

116 """ 

117 return self._value 

118 

119 @value.setter 

120 def value(self, value): 

121 """Sets the value of this LiteralValue. 

122 

123 The value as an object representing the value. Interpret the value object according to the value_type. # noqa: E501 

124 

125 :param value: The value of this LiteralValue. # noqa: E501 

126 :type: object 

127 """ 

128 

129 self._value = value 

130 

131 @property 

132 def source_fn(self): 

133 """Gets the source_fn of this LiteralValue. # noqa: E501 

134 

135 Integer representing index into the fn_array # noqa: E501 

136 

137 :return: The source_fn of this LiteralValue. # noqa: E501 

138 :rtype: int 

139 """ 

140 return self._source_fn 

141 

142 @source_fn.setter 

143 def source_fn(self, source_fn): 

144 """Sets the source_fn of this LiteralValue. 

145 

146 Integer representing index into the fn_array # noqa: E501 

147 

148 :param source_fn: The source_fn of this LiteralValue. # noqa: E501 

149 :type: int 

150 """ 

151 

152 self._source_fn = source_fn 

153 

154 @property 

155 def import_type(self): 

156 """Gets the import_type of this LiteralValue. # noqa: E501 

157 

158 

159 :return: The import_type of this LiteralValue. # noqa: E501 

160 :rtype: ImportType 

161 """ 

162 return self._import_type 

163 

164 @import_type.setter 

165 def import_type(self, import_type): 

166 """Sets the import_type of this LiteralValue. 

167 

168 

169 :param import_type: The import_type of this LiteralValue. # noqa: E501 

170 :type: ImportType 

171 """ 

172 

173 self._import_type = import_type 

174 

175 @property 

176 def import_version(self): 

177 """Gets the import_version of this LiteralValue. # noqa: E501 

178 

179 When value_type is \"literal_function_imported\": the version of the resource being imported (e.g., \"Numpy 1.23.0\") # noqa: E501 

180 

181 :return: The import_version of this LiteralValue. # noqa: E501 

182 :rtype: str 

183 """ 

184 return self._import_version 

185 

186 @import_version.setter 

187 def import_version(self, import_version): 

188 """Sets the import_version of this LiteralValue. 

189 

190 When value_type is \"literal_function_imported\": the version of the resource being imported (e.g., \"Numpy 1.23.0\") # noqa: E501 

191 

192 :param import_version: The import_version of this LiteralValue. # noqa: E501 

193 :type: str 

194 """ 

195 

196 self._import_version = import_version 

197 

198 @property 

199 def import_source(self): 

200 """Gets the import_source of this LiteralValue. # noqa: E501 

201 

202 

203 :return: The import_source of this LiteralValue. # noqa: E501 

204 :rtype: TypedValue 

205 """ 

206 return self._import_source 

207 

208 @import_source.setter 

209 def import_source(self, import_source): 

210 """Sets the import_source of this LiteralValue. 

211 

212 

213 :param import_source: The import_source of this LiteralValue. # noqa: E501 

214 :type: TypedValue 

215 """ 

216 

217 self._import_source = import_source 

218 

219 @property 

220 def source_language(self): 

221 """Gets the source_language of this LiteralValue. # noqa: E501 

222 

223 When function_type is SOURCE or IMPORTED: The source language base name (e.g., \"Python\", \"C\", \"Fortran\") # noqa: E501 

224 

225 :return: The source_language of this LiteralValue. # noqa: E501 

226 :rtype: str 

227 """ 

228 return self._source_language 

229 

230 @source_language.setter 

231 def source_language(self, source_language): 

232 """Sets the source_language of this LiteralValue. 

233 

234 When function_type is SOURCE or IMPORTED: The source language base name (e.g., \"Python\", \"C\", \"Fortran\") # noqa: E501 

235 

236 :param source_language: The source_language of this LiteralValue. # noqa: E501 

237 :type: str 

238 """ 

239 

240 self._source_language = source_language 

241 

242 @property 

243 def source_language_version(self): 

244 """Gets the source_language_version of this LiteralValue. # noqa: E501 

245 

246 When function_type is SOURCE or IMPORTED: The version of the source language (e.g., \"3.10.9\") # noqa: E501 

247 

248 :return: The source_language_version of this LiteralValue. # noqa: E501 

249 :rtype: str 

250 """ 

251 return self._source_language_version 

252 

253 @source_language_version.setter 

254 def source_language_version(self, source_language_version): 

255 """Sets the source_language_version of this LiteralValue. 

256 

257 When function_type is SOURCE or IMPORTED: The version of the source language (e.g., \"3.10.9\") # noqa: E501 

258 

259 :param source_language_version: The source_language_version of this LiteralValue. # noqa: E501 

260 :type: str 

261 """ 

262 

263 self._source_language_version = source_language_version 

264 

265 @property 

266 def gromet_type(self): 

267 """Gets the gromet_type of this LiteralValue. # noqa: E501 

268 

269 

270 :return: The gromet_type of this LiteralValue. # noqa: E501 

271 :rtype: str 

272 """ 

273 return self._gromet_type 

274 

275 @gromet_type.setter 

276 def gromet_type(self, gromet_type): 

277 """Sets the gromet_type of this LiteralValue. 

278 

279 

280 :param gromet_type: The gromet_type of this LiteralValue. # noqa: E501 

281 :type: str 

282 """ 

283 

284 self._gromet_type = gromet_type 

285 

286 def to_dict(self): 

287 """Returns the model properties as a dict""" 

288 result = {} 

289 

290 for attr, _ in six.iteritems(self.swagger_types): 

291 value = getattr(self, attr) 

292 if isinstance(value, list): 

293 result[attr] = list(map( 

294 lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 

295 value 

296 )) 

297 elif hasattr(value, "to_dict"): 

298 result[attr] = value.to_dict() 

299 elif isinstance(value, dict): 

300 result[attr] = dict(map( 

301 lambda item: (item[0], item[1].to_dict()) 

302 if hasattr(item[1], "to_dict") else item, 

303 value.items() 

304 )) 

305 else: 

306 result[attr] = value 

307 if issubclass(LiteralValue, dict): 

308 for key, value in self.items(): 

309 result[key] = value 

310 

311 return result 

312 

313 def to_str(self): 

314 """Returns the string representation of the model""" 

315 return pprint.pformat(self.to_dict()) 

316 

317 def __repr__(self): 

318 """For `print` and `pprint`""" 

319 return self.to_str() 

320 

321 def __eq__(self, other): 

322 """Returns true if both objects are equal""" 

323 if not isinstance(other, LiteralValue): 

324 return False 

325 

326 return self.__dict__ == other.__dict__ 

327 

328 def __ne__(self, other): 

329 """Returns true if both objects are not equal""" 

330 return not self == other