<commit_before>import PyPDF2, os
import sys
import CmdFormat
import shutil

CDMF = CmdFormat.CmdFormat("PDF合并器")


class PDFMerger(object):
    """docstring for PDFMerger"""
    def __init__(self,ROOTPATH,DIRSNAMEs):
        self.__ROOTPATH = ROOTPATH+"\\"
        self.__DIRSNAMEs = DIRSNAMEs
        self.__countriesCount = 0
        self.__currentCoutry=""
        self.bRegenerate = True
    def __checkDirs(self,foldersInACountry):
        if self.__DIRSNAMEs[0] not in foldersInACountry:
            #CDMF.print_red_text("在 "+self.__currentCoutry+" 没有找到 "+ self.__DIRSNAMEs[0]+" !")
            return False
        if self.__DIRSNAMEs[1] not in foldersInACountry:
           # CDMF.print_red_text("在 "+self.__currentCoutry+" 没有找到 "+ self.__DIRSNAMEs[1]+" !")
            return False
        if self.__DIRSNAMEs[2] not in foldersInACountry:
            #CDMF.print_red_text("在 "+self.__currentCoutry+" 没有找到 "+ self.__DIRSNAMEs[2]+" !")
            return False
        return True

    def __messages(self):
        CDMF.set_cmd_color(CmdFormat.FOREGROUND_RED | CmdFormat.FOREGROUND_GREEN | \
            CmdFormat.FOREGROUND_BLUE | CmdFormat.FOREGROUND_INTENSITY)
        print("\n")
        print("==========================  欢迎使用  ==================================")
        print("|                                                                      |")
        print("|      将本程序放在根目录，运行之前请确保根目录下具有                  |")
        CDMF.print_red_text("|      (1) *各个村的目录(一个村一个目录)                               |")
        CDMF.print_red_text("|      (2) *每个村目录下包含<'表3','草图PDF','界址点PDF'>              |")
        print("|      (3) 合并后的文件放在了每个村目录下的<合并>文件夹内              |")
        print("|                                                                      |")
        print("========================================================================")
    def __quiry(self,mes):
        while True:
            content = CDMF.print_green_input_text(mes)
            if content=="y" or content=="Y" or content=="n" or content=="N":
                break
        if content=="y" or content=="Y":
            return True
        else:
            return False

    def __checkRegenerate(self,allCountries):
        isempty = True
        for country in allCountries:
            if os.path.isdir(country):
                self.__currentCoutry = country
                foldersInACountry = os.listdir(country)
                if self.__checkDirs(foldersInACountry):                    
                    coutryPath = os.path.join(self.__ROOTPATH,country)
                    mergerPath = coutryPath + "\\合并\\"
                    if os.path.exists(mergerPath):
                        tempList = os.listdir(mergerPath)
                        if len(tempList)==0:
                            isempty = True
                        else:
                            isempty = False<commit_msg>add tips<commit_after>import PyPDF2, os
import sys
import CmdFormat
import shutil

CDMF = CmdFormat.CmdFormat("PDF合并器")


class PDFMerger(object):
    """docstring for PDFMerger"""
    def __init__(self,ROOTPATH,DIRSNAMEs):
        self.__ROOTPATH = ROOTPATH+"\\"
        self.__DIRSNAMEs = DIRSNAMEs
        self.__countriesCount = 0
        self.__currentCoutry=""
        self.bRegenerate = True
    def __checkDirs(self,foldersInACountry):
        if self.__DIRSNAMEs[0] not in foldersInACountry:
            #CDMF.print_red_text("在 "+self.__currentCoutry+" 没有找到 "+ self.__DIRSNAMEs[0]+" !")
            return False
        if self.__DIRSNAMEs[1] not in foldersInACountry:
           # CDMF.print_red_text("在 "+self.__currentCoutry+" 没有找到 "+ self.__DIRSNAMEs[1]+" !")
            return False
        if self.__DIRSNAMEs[2] not in foldersInACountry:
            #CDMF.print_red_text("在 "+self.__currentCoutry+" 没有找到 "+ self.__DIRSNAMEs[2]+" !")
            return False
        return True

    def __messages(self):
        CDMF.set_cmd_color(CmdFormat.FOREGROUND_RED | CmdFormat.FOREGROUND_GREEN | \
            CmdFormat.FOREGROUND_BLUE | CmdFormat.FOREGROUND_INTENSITY)
        print("\n")
        print("==========================  欢迎使用  ==================================")
        print("|                                                                      |")
        print("|      将本程序放在根目录，运行之前请确保根目录下具有                  |")
        CDMF.print_red_text("|      (1) *各个村的目录(一个村一个目录)                               |")
        CDMF.print_red_text("|      (2) *每个村目录下包含<'表3','草图PDF','界址点PDF'>              |")
        CDMF.print_red_text("|      (3) *请注意以上三个文件夹中的pdf文件需一一对应                  |")
        print("|      (3) 合并后的文件放在了每个村目录下的<合并>文件夹内              |")
        print("|                                                                      |")
        print("========================================================================")
    def __quiry(self,mes):
        while True:
            content = CDMF.print_green_input_text(mes)
            if content=="y" or content=="Y" or content=="n" or content=="N":
                break
        if content=="y" or content=="Y":
            return True
        else:
            return False

    def __checkRegenerate(self,allCountries):
        isempty = True
        for country in allCountries:
            if os.path.isdir(country):
                self.__currentCoutry = country
                foldersInACountry = os.listdir(country)
                if self.__checkDirs(foldersInACountry):                    
                    coutryPath = os.path.join(self.__ROOTPATH,country)
                    mergerPath = coutryPath + "\\合并\\"
                    if os.path.exists(mergerPath):
                        tempList = os.listdir(mergerPath)
                        if len(tempList)==0:
                            isempty = True
                        else:
                            isempty = False
{'fraction_non_alphanumeric': 0.14547926580557444, 'fraction_numerical': 0.004588715159755268, 'mean_word_length': 1.6568848758465011, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7520572', 'n_tokens_mistral': 1803, 'n_tokens_neox': 1794, 'n_words': 289}