Пример #1
0
def getSheetInfos(sheettitle,sheettree):
    arrerrorfiles,arrnewfiles,arrsuccessfiles,arrtreeinfo=[],[],[],[]
    filename=RETool.excludeNumbers(sheettitle)#文件名字可带日期
    datename=RETool.getNumnbers(sheettitle)#文件名对应的日期
    languageNames=ETTool.getAllElementNames(sheettree)#解析出这个表格中配置了多少个语言的文字
   #遍历语言
    for i,v in enumerate(languageNames):
       arrLangFile,arrfilepath,arroldtree=readConfig.arrLanguageFileName(v),[],[]
       for j,k in enumerate(arrLangFile):#遍历语言的对应文件,像法语French就对应着两个文件夹fr_fr,fr_se
            xfilename=readConfig.getOutputPath()+k+"/"+filename+".xml"#保存的文件名字
            hintfilename=k+"/"+filename
            if(False==os.path.isdir(readConfig.getOutputPath()+k)):#不存在目录
                arrerrorfiles.append(hintfilename)
                continue
            elif(os.path.isfile(xfilename)):#存在
                rroot=ETTool.readETRoot(xfilename)
                if(rroot==None):#存在的.xml文件出现错误
                    arrerrorfiles.append(hintfilename)
                    continue
                arrsuccessfiles.append(hintfilename)
            else:#不存在则新建
               rroot=ETTool.createETRoot()
               arrnewfiles.append(hintfilename)
            arrfilepath.append(xfilename)
            arroldtree.append(rroot)
       arrtreeinfo.append(sheetLanguageInfo(v,ETTool.getElement(sheettree,v),arrfilepath,arroldtree))
    return [filename,datename,arrerrorfiles,arrsuccessfiles,arrnewfiles,arrtreeinfo]
Пример #2
0
def readETRoot(spath):
    # etree=ET.parse(spath)
    # return etree.getroot()
    try:
        file=open(file=spath,mode='r',encoding="utf-8")
        str1=file.read()
        file.close()
        str2=RETool.xmlEscape(str1)
        tree = ET.ElementTree(ET.fromstring(str2))
        return tree.getroot()
    except Exception as detaile:
        log.logF("ETTool.py","readETRoot","error path="+str(spath)+" detaile="+str(detaile))
        return None
Пример #3
0
def parseElementChildren(ele,hierarchy,newline,indent):
    arrexclude,tempr,dictag,strr,arrtags=[],[],{},"",[]
    for eles in ele:
        eletag=eles.tag
        arrtags.append(eletag)
        if(len(RETool.getNumnbers(eletag))>0):#get date tag
            tempr=dictag.get(RETool.excludeNumbers(eletag),[])
            tempr.append(eletag)
            dictag[RETool.excludeNumbers(eletag)]=tempr
    for i,v in enumerate(dictag):
        tempr=dictag[v]
        tempr.sort(reverse=True)
        arrexclude.extend(tempr[3:])#exclude old dates,同样的字段,最多只保留3个,比如persontarget20150720 persontarget20150729 persontarget20150829 persontarget20150910,只保留后三个

    arrtags = list(set(arrtags))
    arrtags.sort()# children的输出顺序进行排序
    for i,v in enumerate(arrtags):
        if(v in arrexclude):
            continue
        arrelem=ele.findall(v)
        for k, m in enumerate(arrelem):
            strr+=parseTreeElement(m,hierarchy+1,newline,indent)
    return strr
Пример #4
0
 def getStr(self,arrfiles,shint):
     rstr=""
     if(len(arrfiles)>0):
         rstr+=shint+"\n"+RETool.splitStrArr(arrfiles,4)+"\n"
     return rstr
Пример #5
0
 def checkBtnClick(self):
     self.selectnames=[]
     for i,v in enumerate(self.vars):
         if(v.get()==1):
             self.selectnames.append(self.varnames[i])
     self.master.children["selectformhint"]["text"]="已选择的表格:"+RETool.splitStrArr(self.selectnames,5)