UsingAttrs
- class PlasmaCalcs.tools.oop_tools.manage_attrs.UsingAttrs(obj, attrs_as_dict={}, *, _unset_sentinel=ATTR_UNSET, **attrs_and_values)
Bases:
MaintainingAttrscontext manager which sets attrs of obj upon entry; restores original values upon exit.
This includes deleting any of those attrs upon exit which did not exist upon entry._unset_sentinel: any value, default ATTR_UNSETupon entry, delete any attrs with value _unset_sentinel (compared via ‘is’).E.g. UsingAttrs(obj, _unset_sentinel=None, x=None) –> del obj.x upon entry.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.