@contextlib.contextmanager
def save_lookups():
 namespace_dirs = {namespace: list(look.directories) for (namespace, look) in LOOKUP.items()}
 try:
  (yield)
 finally:
  LOOKUP.clear()
  for (namespace, directories) in namespace_dirs.items():
   for directory in directories:
    add_lookup(namespace, directory)

@ contextlib . contextmanager def save_lookups ( ) : namespace_dirs = { namespace : list ( look . directories ) for ( namespace , look ) in LOOKUP . items ( ) } try : ( yield ) finally : LOOKUP . clear ( ) for ( namespace , directories ) in namespace_dirs . items ( ) : for directory in directories : add_lookup ( namespace , directory )
a context manager to save and restore the mako template lookup path .