def requires(module, name=""):
    """Enforces module presence.

    The general use here is to allow conditional imports that may fail (e.g., a
    required python package is not installed) but still allow the rest of the
    python package to compile and run fine. If the wrapped method with this
    decorated is invoked, then a runtime error is generated.

    :param module: required module (set as variable to ``None`` on import fail)
    :type  module: ``module`` or ``None``
    :param name: module name
    :type  name: ``string``
    """
    def wrapped(method):
        """Call and enforce method."""
        if module is None:
            raise ImproperlyConfigured(name % "Module '%s' is not installed.")
        return method

    return wrapped


###############################################################################
# Date / Time.
###############################################################################
dataset/ETHPy150Open ryan-roemer/django-cloud-browser/cloud_browser/common.py/requires/swapped operands of `%`