def list_all_encodings(p, recursive=False, ignore_nonpy=False):
    """
    List all files in a directory and their encoding.
    :param p: path to directory
    :type p: str
    :param recursive: whether to descend into subdirectories or not
    :type recursive: bool
    :param ignore_nonpy: skip files not ending with .py
    :type ignore_nonpy: bool
    """
    for fn in os.listdir(p):
        fp = os.path.join(p, fn)
        if os.path.isdir(fp):
            if recursive:
                list_all_encodings(fp, recursive=recursive, ignore_nonpy=ignore_nonpy)
        else:
            if (not fn.endswith(".py") and ignore_nonpy):
                # skip
                continue
            show_file_encoding(fp)

    List all files in a directory and their encoding.
    :param p: path to directory
    :type p: str
    :param recursive: whether to descend into subdirectories or not
    :type recursive: bool
    :param ignore_nonpy: skip files not ending with .py
    :type ignore_nonpy: bool
    
tools/encoding_utils.py