Low level implementation of the warning functionality.
    Duplicate of the standard library `warnings.warn_explicit`,
    except it accepts the following arguments:

    `emit_module`: regular expression that should match the module the warnings
                   are emitted from.

def warn_explicit(message, category, filename, lineno,
                      module=None, registry=None, module_globals=None,
                      emit_module=None):
    """
    Low level implementation of the warning functionality.
    Duplicate of the standard library `warnings.warn_explicit`,
    except it accepts the following arguments:

    `emit_module`: regular expression that should match the module the warnings
                   are emitted from.


    """
    lineno = int(lineno)
    if module is None:
        module = filename or "<unknown>"
        if module[-3:].lower() == ".py":
            module = module[:-3]  # XXX What about leading pathname?
    if registry is None:
        registry = {}
    if registry.get('version', 0) != warnings._filters_version:
        registry.clear()
        registry['version'] = warnings._filters_version
    if isinstance(message, Warning):
        text = str(message)
        category = message.__class__
    else:
        text = message
        message = category(message)
    key = (text, category, lineno)
    # Quick test for common case
    if registry.get(key):
        return
    # Search the filters
    for item in warnings.filters:
        item = _get_proxy_filter(item)
        if len(item) == 5:
            action, msg, cat, mod, ln = item
            emod = None
        else:
            action, msg, cat, mod, ln, emod = item
        if ((msg is None or msg.match(text)) and
           issubclass(category, cat) and
           (mod is None or mod.match(module)) and
           (emod is None or emod.match(emit_module)) and
           (ln == 0 or lineno == ln)):
            break
    else:
        action = defaultaction
    # Early exit actions
    if action == "ignore":
        registry[key] = 1
        return

    # Prime the linecache for formatting, in case the
    # "file" is actually in a zipfile or something.
    import linecache
    linecache.getlines(filename, module_globals)

    if action == "error":
        raise message
    # Other actions
    if action == "once":
        registry[key] = 1
        oncekey = (text, category)
        if onceregistry.get(oncekey):
            return
        onceregistry[oncekey] = 1
    elif action == "always":
        pass
    elif action == "module":
        registry[key] = 1
        altkey = (text, category, 0)
        if registry.get(altkey):
            return
        registry[altkey] = 1
    elif action == "default":
        registry[key] = 1
    else:
        # Unrecognized actions are errors
        raise RuntimeError(
            "Unrecognized action (%r) in warnings.filters:\n %s" %
            (action, item))
    if not callable(warnings.showwarning):
        raise TypeError("warnings.showwarning() must be set to a "
                        "function or method")
    # Print message and context
    warnings.showwarning(message, category, filename, lineno)