Get the mtime associated with a module.  If this is a .pyc or .pyo file and
    a corresponding .py file exists, the time of the .py file is returned.

    :param filename: filename of the module.
    :returns: mtime or None if the file doesn"t exist.

def module_getmtime(filename):
    """
    Get the mtime associated with a module.  If this is a .pyc or .pyo file and
    a corresponding .py file exists, the time of the .py file is returned.

    :param filename: filename of the module.
    :returns: mtime or None if the file doesn"t exist.
    """
    if os.path.splitext(filename)[1].lower() in (".pyc", ".pyo") and os.path.exists(filename[:-1]):
        return os.path.getmtime(filename[:-1])
    if os.path.exists(filename):
        return os.path.getmtime(filename)
    return None