def runWithWarningsSuppressed(suppressedWarnings, f, *a, **kw):
 for (args, kwargs) in suppressedWarnings:
  warnings.filterwarnings(*args, **kwargs)
 addedFilters = warnings.filters[:len(suppressedWarnings)]
 try:
  result = f(*a, **kw)
 except:
  exc_info = sys.exc_info()
  _resetWarningFilters(None, addedFilters)
  raise exc_info[0], exc_info[1], exc_info[2]
 else:
  if isinstance(result, defer.Deferred):
   result.addBoth(_resetWarningFilters, addedFilters)
  else:
   _resetWarningFilters(None, addedFilters)
  return result

def runWithWarningsSuppressed ( suppressedWarnings , f , * a , ** kw ) : for ( args , kwargs ) in suppressedWarnings : warnings . filterwarnings ( * args , ** kwargs ) addedFilters = warnings . filters [ : len ( suppressedWarnings ) ] try : result = f ( * a , ** kw ) except : exc_info = sys . exc_info ( ) _resetWarningFilters ( None , addedFilters ) raise exc_info [ 0 ] , exc_info [ 1 ] , exc_info [ 2 ] else : if isinstance ( result , defer . Deferred ) : result . addBoth ( _resetWarningFilters , addedFilters ) else : _resetWarningFilters ( None , addedFilters ) return result
run c{f} .