Mercurial > hgrepos > Python > apps > py-cutils
changeset 115:e15b3d1ff0d9
New subpackage with a "contextlib.nullcontext" for older Python versions
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 29 Dec 2024 15:31:38 +0100 |
| parents | 9e61c5cf76a2 |
| children | 1856374bbd40 |
| files | cutils/util/__init__.py cutils/util/cm.py setup.py |
| diffstat | 3 files changed, 44 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- /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__ = []
--- /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
--- 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",
