#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os


def getInvoicesDir() -> str:
    current_dir = os.getcwd()
    invoices_dir = "invoices"
    invoicesPath = os.path.join(current_dir, invoices_dir)
    return invoicesPath


def ChangeFileExt(path: str, NewExt: str) -> str:
    newFileName = path
    portion = os.path.splitext(path)
    if (len(portion) > 1):
        OldExt = portion[1]
        newFileName =  path.replace(OldExt, NewExt)
    return newFileName

def getAllFiles(folder_path: str, file_extension: str) -> list:
    listFile: list = []
    for root, dirs, files in os.walk(folder_path):
        for file_name in files:
            # 获取文件完整路径
            file_path = os.path.join(root, file_name)
            # 如果是指定类型的文件，则进行处理
            if os.path.isfile(file_path) and os.path.splitext(file_name)[1] == file_extension:
                listFile.append(file_path)
    return listFile


if __name__ == '__main__':
    fileExt = ".pdf"
    invoicesPath = getInvoicesDir()
    pdffiles = getAllFiles(invoicesPath, fileExt)
    getAllFiles('PyCharm')
