From 6381a641d24975fa295d96a87ba7ff2f78b8db52 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Sat, 27 Feb 2016 00:38:03 -0600 Subject: [PATCH] Add SuppressedWarnings context mgr --- islpy/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/islpy/__init__.py b/islpy/__init__.py index d11c708..8765acd 100644 --- a/islpy/__init__.py +++ b/islpy/__init__.py @@ -1238,4 +1238,17 @@ def make_zero_and_vars(set_vars, params=[], ctx=None): return result + +class SuppressedWarnings: + def __init__(self, ctx): + self.ctx = ctx + + def __enter__(self): + self.prev_on_error = self.ctx.get_on_error() + self.ctx.set_on_error(on_error.CONTINUE) + + def __exit__(self, type, value, traceback): + self.ctx.set_on_error(self.prev_on_error) + + # vim: foldmethod=marker -- GitLab