X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=blobdiff_plain;f=lib%2Fbup%2Fhelpers.py;h=0530b51aa81575dadf67fd2101c507be31607beb;hp=3b37a2b72c065eccf1f9610575a1ee3f90212a8c;hb=1eb38bb8e0c63d02a4672d4beeccafe06dba3d04;hpb=13144702fca874fe40b08ef630f4b34ebaabc6a5 diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index 3b37a2b..0530b51 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -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