@contextmanager
    def saved_context( self , **kargs):
        """Saves the context of this p4 object and restores it again at the end of the block"""
    
        saved_context = {}
        for attr in self.__members__:
            saved_context[attr] = getattr(self, attr)
    
        for (k,v) in kargs.items():
            setattr( self, k, v)
        
        yield
        
        # now restore the context again. Ignore AttributeError exception
        # Exception is expected because some attributes only have getters, no setters
        
        for (k,v) in saved_context.items():
            try:
                setattr( self, k, v )
            except __HOLE__:
                pass # expected for server_level and p4config_file
dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/common/perforce/p426/win64/P4.py/P4.saved_context