def context_cache(func):
 def context_cache_wrap(*args, **kwargs):
  func_context = func.__globals__['__context__']
  func_opts = func.__globals__['__opts__']
  func_name = func.__globals__['__name__']
  context_cache = ContextCache(func_opts, func_name)
  if ((not func_context) and os.path.isfile(context_cache.cache_path)):
   salt.utils.dictupdate.update(func_context, context_cache.get_cache_context())
  else:
   context_cache.cache_context(func_context)
  return func(*args, **kwargs)
 return context_cache_wrap

def context_cache ( func ) : def context_cache_wrap ( * args , ** kwargs ) : func_context = func . __globals__ [ '__context__' ] func_opts = func . __globals__ [ '__opts__' ] func_name = func . __globals__ [ '__name__' ] context_cache = ContextCache ( func_opts , func_name ) if ( ( not func_context ) and os . path . isfile ( context_cache . cache_path ) ) : salt . utils . dictupdate . update ( func_context , context_cache . get_cache_context ( ) ) else : context_cache . cache_context ( func_context ) return func ( * args , ** kwargs ) return context_cache_wrap
a decorator to be used module functions which need to cache their context .