# HG changeset patch # User Franz Glasner # Date 1735482698 -3600 # Node ID e15b3d1ff0d95bbc3914d98a83144c1a854aca28 # Parent 9e61c5cf76a2d780d0190489de5760a8d13ed681 New subpackage with a "contextlib.nullcontext" for older Python versions diff -r 9e61c5cf76a2 -r e15b3d1ff0d9 cutils/util/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cutils/util/__init__.py Sun Dec 29 15:31:38 2024 +0100 @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# :- +# :Copyright: (c) 2020-2024 Franz Glasner +# :License: BSD-3-Clause +# :- +r"""Utility package. + +""" + +__all__ = [] diff -r 9e61c5cf76a2 -r e15b3d1ff0d9 cutils/util/cm.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cutils/util/cm.py Sun Dec 29 15:31:38 2024 +0100 @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# :- +# :Copyright: (c) 2020-2024 Franz Glasner +# :License: BSD-3-Clause +# :- +r"""Context manager extensions and compatibility. + +""" + +__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 diff -r 9e61c5cf76a2 -r e15b3d1ff0d9 setup.py --- a/setup.py Mon Dec 23 20:01:25 2024 +0100 +++ b/setup.py Sun Dec 29 15:31:38 2024 +0100 @@ -31,9 +31,9 @@ author="Franz Glasner", license="""BSD 3-Clause "New" or "Revised" License""", url="https://pypi.dom66.de/simple/py-cutils/", - description="Pure Python implementation of some coreutils", + description="Pure Python implementation of some coreutils with some extensions", long_description=long_description, - packages=["cutils",], + packages=["cutils", "cutils.util"], include_package_data=False, zip_safe=True, platforms="any",