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

Class ModelNormal

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

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

Source from the content-addressed store, hash-verified

485
486
487class ModelNormal(OpenApiModel):
488 """the parent class of models whose type == object in their
489 swagger/openapi"""
490
491 def __setitem__(self, name, value):
492 """set the value of an attribute using square-bracket notation: `instance[attr] = val`"""
493 if name in self.required_properties:
494 self.__dict__[name] = value
495 return
496
497 self.set_attribute(name, value)
498
499 def get(self, name, default=None):
500 """returns the value of an attribute or some default value if the attribute was not set"""
501 if name in self.required_properties:
502 return self.__dict__[name]
503
504 return self.__dict__["_data_store"].get(name, default)
505
506 def __getitem__(self, name):
507 """get the value of an attribute using square-bracket notation: `instance[attr]`"""
508 if name in self:
509 return self.get(name)
510
511 raise ApiAttributeError(
512 "{0} has no attribute '{1}'".format(type(self).__name__, name),
513 [e for e in [self._path_to_item, name] if e],
514 )
515
516 def __contains__(self, name):
517 """used by `in` operator to check if an attribute value was set in an instance: `'attr' in instance`"""
518 if name in self.required_properties:
519 return name in self.__dict__
520
521 return name in self.__dict__["_data_store"]
522
523 def to_dict(self):
524 """Returns the model properties as a dict"""
525 return model_to_dict(self, serialize=False)
526
527 def to_str(self):
528 """Returns the string representation of the model"""
529 return pprint.pformat(self.to_dict())
530
531 def __eq__(self, other):
532 """Returns true if both objects are equal"""
533 if not isinstance(other, self.__class__):
534 return False
535
536 if not set(self._data_store.keys()) == set(other._data_store.keys()):
537 return False
538 for _var_name, this_val in self._data_store.items():
539 that_val = other._data_store[_var_name]
540 types = set()
541 types.add(this_val.__class__)
542 types.add(that_val.__class__)
543 vals_equal = this_val == that_val
544 if not vals_equal:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected