view cutils/util/cm.py @ 275:c72f5b2dbc6f

treesum: Simplify the path computations and make the visible output more consistent. Current format of digest lines: - No `=' if there was a severe error so that digest and/or size could not be computed. - Empty fields for digest and/or size of they were not computed on purpose: * for symbolic links * for special files
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 20 Feb 2025 15:30:51 +0100
parents 0f4febf646f5
children 48430941c18c
line wrap: on
line source

# -*- coding: utf-8 -*-
# :-
# :Copyright: (c) 2020-2025 Franz Glasner
# :License:   BSD-3-Clause
# :-
r"""Context manager extensions and compatibility.

"""

from __future__ import print_function, absolute_import


__all__ = ["nullcontext"]


try:
    from contextlib import nullcontext
except ImportError:
    class nullcontext(object):

        """Compatibility implementation for systems that are missing yet
        a standard :class:`contextlib.nullcontext`.

        """

        __slots__ = ("thing", )

        def __init__(self, thing=None):
            self.thing = thing

        def __enter__(self):
            return self.thing

        def __exit__(self, *args, **kwds):
            pass