def _open_shelve(shelffn, withclosing=False):
 import shelve
 shelf = shelve.open(shelffn, protocol=2)
 if withclosing:
  return contextlib.closing(shelf)
 else:
  return shelf

def _open_shelve ( shelffn , withclosing = False ) : import shelve shelf = shelve . open ( shelffn , protocol = 2 ) if withclosing : return contextlib . closing ( shelf ) else : return shelf
opens a shelf file .