Get relative filepaths of files in a directory, and sub-directories,
    with the given extension.

    Parameters
    ----------
    extname : `str`
        Extension name (e.g. 'txt', 'rst'). Extension comparison is
        case-insensitive.
    root_dir : `str`, optional
        Root directory. Current working directory by default.

    Returns
    -------
    filepaths : `list` of `str`
        File paths, relative to ``root_dir``, with the given extension.

def get_filepaths_with_extension(extname, root_dir='.'):
    """Get relative filepaths of files in a directory, and sub-directories,
    with the given extension.

    Parameters
    ----------
    extname : `str`
        Extension name (e.g. 'txt', 'rst'). Extension comparison is
        case-insensitive.
    root_dir : `str`, optional
        Root directory. Current working directory by default.

    Returns
    -------
    filepaths : `list` of `str`
        File paths, relative to ``root_dir``, with the given extension.
    """
    # needed for comparison with os.path.splitext
    if not extname.startswith('.'):
        extname = '.' + extname

    # for case-insensitivity
    extname = extname.lower()

    root_dir = os.path.abspath(root_dir)

    selected_filenames = []
    for dirname, sub_dirnames, filenames in os.walk(root_dir):
        for filename in filenames:
            if os.path.splitext(filename)[-1].lower() == extname:
                full_filename = os.path.join(dirname, filename)
                selected_filenames.append(
                    os.path.relpath(full_filename, start=root_dir))
    return selected_filenames