Metadata-Version: 2.1
Name: conditional
Version: 1.3
Summary: Conditionally enter a context manager
Home-page: https://github.com/stefanholek/conditional
Author: Stefan H. Holek
Author-email: stefan@epy.co.at
License: BSD-2-Clause
Keywords: conditional context manager with
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
License-File: LICENSE

===========
conditional
===========
-------------------------------------------------------------------
Conditionally enter a context manager
-------------------------------------------------------------------

Package Contents
================

conditional(condition, contextmanager)
    Enter contextmanager only if condition is true.

Overview
========

The *conditional* context manager comes handy when you always want to
execute a with-block but only conditionally want to apply its context
manager.

If you find yourself writing code like this::

    if CONDITION:
        with CONTEXTMANAGER():
            BODY()
    else:
        BODY()

Consider replacing it with::

    with conditional(CONDITION, CONTEXTMANAGER()):
        BODY()

Examples
========

Say we want to ignore signals when a pager application is in the
foreground, but not otherwise::

    from conditional import conditional

    with conditional(has_pager(cmd), ignoresignals()):
        os.system(cmd)

Documentation
=============

For further details please refer to the `API Documentation`_.

.. _`API Documentation`: https://conditional.readthedocs.io/en/stable/


Changelog
=========

1.3 - 2019-01-28
----------------

- Add MANIFEST.in.
  [stefan]

- Release as wheel.
  [stefan]

1.2 - 2017-02-05
----------------

- Support Python 2.6-3.6 without 2to3.
  [stefan]

- Add a LICENSE file.
  [stefan]

1.1 - 2014-04-19
----------------

- Remove setuptools from install_requires because it isn't.
  [stefan]

1.0 - 2012-05-16
----------------

- Initial release.
  [stefan]
