MCPcopy Create free account
hub / github.com/bundesAPI/smard-api / ModelSimple

Class ModelSimple

python-client/deutschland/smard/model_utils.py:433–484  ·  view source on GitHub ↗

the parent class of models whose type != object in their swagger/openapi

Source from the content-addressed store, hash-verified

431
432
433class ModelSimple(OpenApiModel):
434 """the parent class of models whose type != object in their
435 swagger/openapi"""
436
437 def __setitem__(self, name, value):
438 """set the value of an attribute using square-bracket notation: `instance[attr] = val`"""
439 if name in self.required_properties:
440 self.__dict__[name] = value
441 return
442
443 self.set_attribute(name, value)
444
445 def get(self, name, default=None):
446 """returns the value of an attribute or some default value if the attribute was not set"""
447 if name in self.required_properties:
448 return self.__dict__[name]
449
450 return self.__dict__["_data_store"].get(name, default)
451
452 def __getitem__(self, name):
453 """get the value of an attribute using square-bracket notation: `instance[attr]`"""
454 if name in self:
455 return self.get(name)
456
457 raise ApiAttributeError(
458 "{0} has no attribute '{1}'".format(type(self).__name__, name),
459 [e for e in [self._path_to_item, name] if e],
460 )
461
462 def __contains__(self, name):
463 """used by `in` operator to check if an attribute value was set in an instance: `'attr' in instance`"""
464 if name in self.required_properties:
465 return name in self.__dict__
466
467 return name in self.__dict__["_data_store"]
468
469 def to_str(self):
470 """Returns the string representation of the model"""
471 return str(self.value)
472
473 def __eq__(self, other):
474 """Returns true if both objects are equal"""
475 if not isinstance(other, self.__class__):
476 return False
477
478 this_val = self._data_store["value"]
479 that_val = other._data_store["value"]
480 types = set()
481 types.add(this_val.__class__)
482 types.add(that_val.__class__)
483 vals_equal = this_val == that_val
484 return vals_equal
485
486
487class ModelNormal(OpenApiModel):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected