MaintainingAttrs
- class PlasmaCalcs.tools.oop_tools.manage_attrs.MaintainingAttrs(obj, *attrs, **attrs_as_flags)
Bases:
objectcontext manager which restores attrs of obj to their original values, upon exit.
This includes deleting any of those attrs upon exit which did not exist upon entry.kwargs can be provided with key=bool; attr key will be included if True.E.g. MaintainingAttrs(obj, ‘attr1’, ‘attr2’, attr3=True, attr4=False)–> will maintain obj.attr1, obj.attr2, and obj.attr3, but not obj.attr4.Methods
take all steps related to attrs which should occur upon entry.
take all steps related to attrs which should occur upon exit.
tells whether currently inside attrs handling for self.
return dict of {attr: obj.attr} for current values of attrs.
Attributes
_unset_sentinel- enter_handle_attrs()
take all steps related to attrs which should occur upon entry.
Provided separately from self.__enter__ for access to low-level functionality.
- exit_handle_attrs()
take all steps related to attrs which should occur upon exit.
Provided separately from self.__exit__ for access to low-level functionality.
- inside_attrs()
tells whether currently inside attrs handling for self. None if never entered; False if exited.
- obj_current_attrs()
return dict of {attr: obj.attr} for current values of attrs.