From 3b85a515b5080a44c150e9105c6ab9dccae72903 Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Thu, 14 Apr 2016 11:07:39 +0200
Subject: [PATCH] Add a delete option to the cache_context

---
 python/dune/perftool/generation/context.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/python/dune/perftool/generation/context.py b/python/dune/perftool/generation/context.py
index d96e7e9c..85ea60a9 100644
--- a/python/dune/perftool/generation/context.py
+++ b/python/dune/perftool/generation/context.py
@@ -5,8 +5,9 @@ _cache_context_stack = []
 
 
 class _CacheContext(object):
-    def __init__(self, tags):
+    def __init__(self, tags, delete=False):
         self.tags = tags
+        self.delete = delete
 
     def __enter__(self):
         _cache_context_stack.append(self.tags)
@@ -14,9 +15,13 @@ class _CacheContext(object):
     def __exit__(self, exc_type, exc_value, traceback):
         _cache_context_stack.pop()
 
+        if self.delete:
+            from dune.perftool.generation.cache import delete_cache_items
+            delete_cache_items(condition=" and ".join(self.tags))
 
-def cache_context(*tags):
-    return _CacheContext(tags)
+
+def cache_context(*tags, **kwargs):
+    return _CacheContext(tags, **kwargs)
 
 
 def get_context_tags():
-- 
GitLab