]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/helpers.py
Fully (and explicitly) close PackIdxLists
[bup.git] / lib / bup / helpers.py
index 3b37a2b72c065eccf1f9610575a1ee3f90212a8c..0530b51aa81575dadf67fd2101c507be31607beb 100644 (file)
@@ -12,7 +12,7 @@ import hashlib, heapq, math, operator, time, tempfile
 
 from bup import _helpers
 from bup import compat
-from bup.compat import argv_bytes, byte_int, pending_raise
+from bup.compat import argv_bytes, byte_int, nullcontext, pending_raise
 from bup.io import byte_stream, path_msg
 # This function should really be in helpers, not in bup.options.  But we
 # want options.py to be standalone so people can include it in other projects.
@@ -27,6 +27,10 @@ class Nonlocal:
     pass
 
 
+def nullcontext_if_not(manager):
+    return manager if manager is not None else nullcontext()
+
+
 @contextmanager
 def finalized(enter_result=None, finalize=None):
     assert finalize