'''
from wand.image import Image

'''

import os
# import fitz
# import pymupdf

import camelot

'''
发票头
'''


'''
import io
import pyocr
import pyocr.builders
from PIL import Image as PI
import pandas as pd
import re
import shutil
import openpyxl
# from wand.image import Image  # 为啥直接导入有错误?
import wand
'''


def GetTicketPath():
    curpath = os.getcwd()
    subpath = "\\ticket\\"
    absPath = curpath + subpath
    return absPath


def GetTickHeaderInfo(fileFullPath: str) -> tuple:
    '''
    获取发票文件头信息
    :param fileFullPath:
    :return:
    '''
    tables = camelot.read_pdf(fileFullPath, shift_text=[''], strip_text='\n')
    table = tables[0].df  # 将发票表格转换为dataframe
    price = table[10][2][1:]
    if len(price) == 0:
        price = table[9][2][-6:]
    tuple_Info: tuple = ()

    '''
    doc = fitz.open(fileFullPath)
    page = doc.load_page(0)

    # block格式: x0, y0, x1, y1, "提取的内容", block_no, block_typ(1:image, 0:text)
    blocks = page.get_textpage().extractBLOCKS()
    for block in blocks:
        for other_block in blocks:
            if other_block[5] == block[5]:
                continue
            if abs(block[2] - other_block[0]) < 10 and abs(block[1] - other_block[1]) < 3:
                receipt_info[block[4].strip()] = other_block[4]
    '''
    return tuple_Info


def GetTickDetailInfo(fileFullPath: str) -> tuple:
    '''
    获取发票详细信息
    :param fileFullPath:
    :return:
    '''

    tuple_Info: tuple = ()

    return tuple_Info


if __name__ == '__main__':
    path = GetTicketPath()
    print(path)
