def main():
    allTsFile = et.getFileName(tsFile, ["ts"], [])
    allExmlFile = et.getFileName(exmlFile, ["exml"], [])
    tsIDIdx = 1231
    xmlIDIdx = 729
    xml_t = {}
    for xml in allExmlFile:
        line = ""
        with open(xml, 'r') as f:
            line = f.read()
            #line = line.replace(EXMLTRANSLATESTR, "xmlList_")
            #用两点 拆分 如果有中文 / 如果 有 19... 说明有问题 打印出来 没有直接替换
            dd = line.split('"')
            for i in range(len(dd)):
                if i % 2 != 0:
                    s = dd[i]
                    if et.isIncludeChinese(s):
                        if s.find(EXMLTRANSLATESTR) > -1:
                            print("文件有问题 = >" + xml, "s = >" + s)
                        else:
                            k = getTableKey(xml_t, s)
                            # 是否已经换过的值
                            if k:
                                _k = k.replace("_", "")
                            else:
                                xml_t["_" + str(xmlIDIdx)] = s
                                _k = xmlIDIdx
                                xmlIDIdx = xmlIDIdx + 1
                            print("xmlID = > ", _k, "replace Str = > ", s,
                                  "file = >" + xml)
                            line = line.replace(
                                s, str(EXMLTRANSLATESTR + str(_k)))
            # strList = et.getChineseStr(line)
            # if len(strList) > 0:
            #     for s in strList:
            #         k = getTableKey(xml_t, s)
            #         # 是否已经换过的值
            #         _k = 0
            #         if k:
            #             _k = k.replace("_","")
            #         else:
            #             xml_t["_"+str(xmlIDIdx) ] = s
            #             _k = xmlIDIdx
            #             xmlIDIdx = xmlIDIdx+1
            #         print("xmlID = > ", _k, "replace Str = > ", s)
            #         line = line.replace(s, str(EXMLTRANSLATESTR + str(_k) ))
        with open(xml, 'w') as f:
            f.write(line)
Ejemplo n.º 2
0
def makeCoffeeTranslate(coffeeSql, coffeeFile):
    print("begin makeCoffeeTranslate")
    # 打开数据库连接
    # db = pymysql.connect("192.168.1.207", "root", "", "CHARACTER_SETS")
    db = pymysql.connect(host=host,
                         port=port,
                         user=user,
                         passwd=passwd,
                         db=database,
                         charset='utf8mb4')
    cursor = db.cursor()
    allList = et.excelToList(coffeeFile)["RECORDS"]
    for item in allList:
        ID = item[0]
        vit = item[2]
        # SQL 查询语句
        if item[0] == 'Id':
            continue
        sql = coffeeSql.format(vit, str(int(ID)))
        print(sql)
        try:
            # 执行SQL语句
            cursor.execute(sql)
            db.commit()
            # 获取所有记录列表
            print(cursor.rowcount)
        except:
            print("Error: unable to fetch data")

    # 关闭数据库连接
    db.close()
    print("begin makeCoffeeTranslate success")
def splitOneXlsToXlsFile(xlsFile):
    if not xlsFile:
        print("no xls file for split !!!")
        return
    dddd = et.excelToList(xlsFile)
    for k in dddd:
        for i in range(len((dddd[k]))):
            if i == 0:
                for j in range(len((dddd[k][i]))):
                    #todo  可以无限加  smjb
                    dddd[k][i][j] = dddd[k][i][j].replace('序号', 'Id')
                    dddd[k][i][j] = dddd[k][i][j].replace('英文', 'English')
                    dddd[k][i][j] = dddd[k][i][j].replace('越南', 'Vietnam')
    for k in dddd:
        dat = {}
        dat[k] = dddd[k]
        fPath, fname = os.path.split(xlsFile)
        saveXlsFile = fPath + splitFile + k + ".xls"
        if not os.path.isdir(fPath + splitFile):
            mkdir(fPath + splitFile)
        et.makeExcel(dat, saveXlsFile)
Ejemplo n.º 4
0
    with open(filelow, 'r') as enf:
        cont = enf.read()
    with open(fileMore, 'r') as f:
        li = f.readlines()
        for l in li:
            if l.find("->") > -1:
                if cont.find(l) == -1:
                    print("错误文件 ==>   " + fileMore)
                    print(l)


if __name__ == '__main__':
    # cont = ''
    # with open(enFile, 'r') as enf:
    #     cont = enf.read()
    # with open(chFile, 'r') as f:
    #     li = f.readlines()
    #     for l in li:
    #         if l.find("EasyCommon") > -1:
    #             if cont.find(l) == -1:
    #                 print(l)

    print("done")

    print("其他文件")

    allcncoffee = et.getFileName(chFile, ['coffee'], [])
    allEnCoffee = et.getFileName(enFile, ['coffee'], [])

    for f in allcncoffee:
        printDiffFunc(f, f.replace(chFile, enFile))
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
# @Time    : 2018/12/19 下午6:01

# 冬季皮肤替换
import easyGameTool.foreignTools.cocosPikachuTools.ExcelTools as et
import os

isShenDan = True

shendanFile = '/Users/admin/Documents/ljworkspace/local/cocos/assets/pikachu/sanguo/art_pikachu/动画/替换怪物/节日精灵/圣诞'

baseFile = "/Users/admin/Documents/ljworkspace/local/cocos/assets/pikachu/sanguo/art_pikachu/动画/替换怪物"

projectFile = '/Users/admin/Documents/ljworkspace/local/cocos/project/pikachu_russion/app/static/res/unit'

if __name__ == '__main__':

    allImgFile = et.getFileOnlyName(shendanFile, ["png"])

    for f in allImgFile:
        fp, fn = os.path.split(f)
        if not isShenDan:
            shendanFile = baseFile

        et.copyfile(shendanFile + "/" + fn, projectFile + "/" + fn)

    pass
Ejemplo n.º 6
0
def printDiffFunc(fileMore):
    global insertCount
    fp, fn = os.path.split(fileMore)
    li = ''
    with open(fileMore, 'r') as f:
        li = f.readlines()
        for j in range(li.__len__()):
            l = li[j]
            isEx = False
            for ee in ex:
                if l.find(ee) > -1:
                    isEx = True
            if l.find('#') > -1:
                isEx = True
            if isEx:
                continue
            chineseList = et.getChineseStr(l)
            if len(chineseList) > 0:
                for ch in chineseList:
                    if l.find('"' + ch) > -1 or l.find("'" + ch) > -1:
                        id = getIdFormData(allCoffeeData, ch)
                        isHasData = True
                        if not id:
                            isHasData = False
                            id = getMaxID(allCoffeeData) + 1
                        # 做替换
                        oneDocList = l.split("'")

                        for ii in range(oneDocList.__len__()):
                            if oneDocList[ii].find(ch) > -1:
                                oldStr = "'" + oneDocList[ii] + "'"
                                llll = copy.deepcopy(li[j])

                                li[j] = li[j].replace(
                                    oldStr, "getTranslateStr(" + str(id) + ")")
                                if not isHasData and oldStr in llll:
                                    # insert
                                    print("need insert id = >> " + str(id))
                                    isInsertedID = getInsterIdx(
                                        needInsert, oneDocList[ii])

                                    if isInsertedID == None:
                                        needInsert.append({
                                            "Id": id,
                                            "ch": oneDocList[ii],
                                            "file": fn
                                        })
                                        insertCount = insertCount + 1
                                    else:
                                        dat = needInsert[isInsertedID]
                                        if fn in dat["file"]:
                                            fileName = dat["file"]
                                        else:
                                            fileName = dat["file"] + ";" + fn
                                        needInsert[isInsertedID] = {
                                            "Id": dat["Id"],
                                            "ch": dat["ch"],
                                            "file": fileName
                                        }

                        oneDocList = l.split('"')
                        for ii in range(oneDocList.__len__()):
                            if oneDocList[ii].find(ch) > -1:
                                oldStr = '"' + oneDocList[ii] + '"'
                                llll = copy.deepcopy(li[j])
                                li[j] = li[j].replace(
                                    oldStr, "getTranslateStr(" + str(id) + ")")
                                if not isHasData and oldStr in llll:
                                    # insert
                                    print("need insert id = >> " + str(id))
                                    isInsertedID = getInsterIdx(
                                        needInsert, oneDocList[ii])
                                    if isInsertedID == None:
                                        needInsert.append({
                                            "Id": id,
                                            "ch": oneDocList[ii],
                                            "file": fn
                                        })
                                        insertCount = insertCount + 1
                                    else:
                                        dat = needInsert[isInsertedID]
                                        if fn in dat["file"]:
                                            fileName = dat["file"]
                                        else:
                                            fileName = dat["file"] + ";" + fn
                                        needInsert[isInsertedID] = {
                                            "Id": dat["Id"],
                                            "ch": dat["ch"],
                                            "file": fileName
                                        }
                            # et.processSql()
                        print("file = >> " + fileMore)
                        print(ch)
    with open(fileMore, 'w') as ff:
        ff.writelines(li)
Ejemplo n.º 7
0
# -*- coding: utf-8 -*-
# @Time    : 2019/2/28 下午4:46

# TODO 期望获取文件中的 中文  打到提取中文 并且替换中文 到新的 id 新的id  会insert 到 数据库里面
chFile = '/Users/admin/Documents/ljworkspace/local/cocos/project/Pikachu/app/static/coffee'  # /commons/EasyCommon.coffee
enFile = '/Users/admin/Documents/ljworkspace/local/cocos/project/pikachu_englishGit/pikachu_english/app/static/coffee'  # /commons/EasyCommon.coffee

import easyGameTool.foreignTools.cocosPikachuTools.ExcelTools as et
import os
import copy

allCoffee = et.getFileName(enFile, ["coffee"], [])

ex = ["log"]  # '{0}' WHERE Id={1}
allCoffeeData = None
allCoffeeData = et.processSql(
    "SELECT Id,Chinese from coffeeTranslate WHERE Id IS NOT NULL and Id != 0")

insterSql = "INSERT INTO coffeeTranslate (Id,Chinese, FilePth) VALUES ('{0}','{1}','{2}')"

insertCount = 0

needInsert = []


def getIdFormData(allData, chStr):
    for row in allData:
        if row[1] == chStr:
            print("id == > " + str(row[0]) + "  str = > " + row[1])
            return row[0]
def printDiffFunc(fileMore):
    global insertCount
    fp, fn = os.path.split(fileMore)
    li = ''
    l = ''
    with open(fileMore, 'r') as f:
        li = f.read()
        l = li
        # 通过 string 分割 然后 只取 奇数的部分 里面只有内容  并且 包括lbl text
        allSp = l.split("string")
        allStr = []
        for s in range(len(allSp)):
            if s % 2 == 1:
                allStr.append(allSp[s].replace("</",
                                               "").replace(">", "").replace(
                                                   "\n", "").replace("\t", ""))
        chineseList = []
        for s in allStr:
            if et.isIncludeChinese(s):
                chineseList.append(s)
        #chineseList = et.getChineseStr(l)
        if len(chineseList) > 0:
            for ch in chineseList:
                needDe = False
                for p in ex:
                    if ch.find(p) > -1:
                        needDe = True
                if needDe:
                    continue

                id = getIdFormData(allCoffeeData, ch)
                isHasData = True
                if not id:
                    isHasData = False
                    id = getMaxID(allCoffeeData) + 1
                # 做替换

                if (">" + ch + "<") in l or ((">" + ch + "\n<") in l):
                    l = l.replace(ch, "ccbList_" + str(id))

                    if not isHasData:
                        # insert
                        print("need insert id = >> " + str(id))
                        isInsertedID = getInsterIdx(needInsert, ch)

                        if isInsertedID == None:
                            needInsert.append({"Id": id, "ch": ch, "file": fn})
                            insertCount = insertCount + 1
                        else:
                            dat = needInsert[isInsertedID]
                            if fn in dat["file"]:
                                fileName = dat["file"]
                            else:
                                fileName = dat["file"] + ";" + fn
                            needInsert[isInsertedID] = {
                                "Id": dat["Id"],
                                "ch": dat["ch"],
                                "file": fileName
                            }
                        # et.processSql()
                    print("file = >> " + fileMore)
                    print(ch)
    with open(fileMore, 'w') as ff:
        ff.writelines(l)
Ejemplo n.º 9
0
outFile = ''

imgList = [
    'UI_VIP_zishebeijing.jpg',
    'cz_zti3.png',
    'ui_zhaunsdj.png',
    'zzz_yff.png',
    "qy_204k.png",
    "ui_dshoq.png",
    "doq_diksmgz.jpg",
]

if __name__ == '__main__':

    allPsdFile = et.getFileName(CF.MACMINI_COCOS_ALLPSDPATH, ["psd"], [])
    allImgDir = {}
    for _path in imgList:
        allImgDir[_path] = 0

    for _path in allPsdFile:
        fp, fn = os.path.split(_path)
        if fn.split('.').pop() == 'psd':
            if fn.replace("psd", "png") in imgList:
                et.copyfile(_path, '/Users/admin/Desktop/psd/' + fn)
                allImgDir[fn.replace("psd", "png")] = 1
            if fn.replace("psd", "jpg") in imgList:
                et.copyfile(_path, '/Users/admin/Desktop/psd/' + fn)
                allImgDir[fn.replace("psd", "jpg")] = 1

    for _name in allImgDir:
Ejemplo n.º 10
0
    resObj = {}
    resObj["pkgID"] = tree._root.attrib["id"]
    resList = []
    nodes = xmlTool.find_nodes(tree, "resources/")
    for node in nodes:
        if node.tag == 'image':
            if not node.attrib:
                continue
            if 'exported' in node.attrib:
                if node.attrib['exported'] == 'true':
                    resList.append(node.attrib)
    resObj["imgList"] = resList
    resObj['localFile'] = pkgXml
    return resObj


if __name__ == '__main__':
    localPkg = {}
    assestFile = fairyGuiProFile + 'assets/'
    allPackageFile = Et.getFileName(assestFile, ['xml'], [])
    allpkgxml = list(filter(isPackAgeXml, allPackageFile))
    # 把所有的packagexml 解析一遍 看 引用 对不对
    for i in allpkgxml:
        pkgName = getPackAgeNameByPath(i)
        if pkgName not in localPkg:
            localPkg[pkgName] = []
            localPkg[pkgName] = getPkgImgID(i)
    # 每个 组件 单独处理一下 查看是否有 id 引用错误的
    for fi in allPackageFile:
        checkErrorID(fi, localPkg)
Ejemplo n.º 11
0
# -*- coding: utf-8 -*-
# @Time    : 2018/12/19 下午6:01

# 冬季皮肤替换
import easyGameTool.foreignTools.cocosPikachuTools.ExcelTools as et
import os

ch = "/Users/admin/Documents/ljworkspace/local/cocos/project/Pikachu/tools/pikachuCCB/ccb"

en = "/Users/admin/Documents/ljworkspace/local/cocos/project/pikachu_englishGit/pikachu_english/tools/pikachuCCB/ccb"

ccbname = "FormChooseLevelPart"
#
#

if __name__ == '__main__':

    allImgFile = et.getFileName(ch, ["ccb"])

    for f in allImgFile:
        fp, fn = os.path.split(f)
        if fn == ccbname + ".ccb":
            et.copyfile(f, en + "/" + fn)

    pass

#ccbList_352
Ejemplo n.º 12
0
# -*- coding: utf-8 -*-
# @Time    : 2018/10/17 下午2:58
'''  发布 ccb 的   '''
import os

import easyGameTool.foreignTools.cocosPikachuTools.ExcelTools as et

alsh = et.getFileName(
    '/Users/admin/Documents/ljworkspace/local/cocos/project/pikachu_vietnam/pikachu_english/tools/pikachuFontAndPlist/bin',
    ["sh"], [])
for i in alsh:
    os.system("sh " + i)
Ejemplo n.º 13
0
# -*- coding: utf-8 -*-
# @Time    : 2019/2/16 下午4:17

#把 所有的图片  放一块 找没翻译的...  c

import easyGameTool.foreignTools.cocosPikachuTools.ExcelTools as et
import easyGameTool.projectConfig as cf
import os

if __name__ == '__main__':
    allTsFile = et.getFileName(
        "/Users/admin/Documents/ljworkspace/local/egret/ProStoneAge/ProStoneAge/tools/sheets",
        ["png", "jpg"], [])
    allTsFile = et.getFileName(
        "/Users/admin/Documents/ljworkspace/local/egret/ProStoneAge/ProStoneAge/StoneAppPro/resource/images",
        ["png", "jpg"], allTsFile)
    for f in allTsFile:
        fp, fn = os.path.split(f)
        et.copyfile(f, "/Users/admin/Desktop/ffushiqitupian/" + fn)
    pass
Ejemplo n.º 14
0
def checkIsHasBtnCb(fileName, btnName):
    if fileName.find("Mediator") > -1 or fileName.find(
            "Meditor") > -1:  # meditor  btnexit1
        if btnName.find('btnExit') == 0 or btnName.find('btnClose') == 0:
            return True
    with open(fileName, 'r') as f:
        line = f.readlines()
        for i in range(0, len(line)):
            l = line[i]
            if l.find(btnName + ".setCall") > -1:
                return True
    return False


if __name__ == '__main__':
    allExmlFile = et.getFileName(pro, ["exml"], [])
    allTsFile = et.getFileName(ts, ["ts"], [])
    allXlsCount = len(allExmlFile)
    idx = 0

    for exml in allExmlFile:
        # if exml.find("NodeActivityShenShou") > -1:
        #     print("ssss")
        idx = idx + 1
        btnID = fundAllBtnExit(exml)

        # print(exml + "不存在 btnid ") 不存在的 不管
        print("执行了==>>" + str(idx / allXlsCount))
        if btnID:
            exmlFp, exmlFn = os.path.split(exml)
            # 先通过 xml z找到 ts
Ejemplo n.º 15
0
# -*- coding: utf-8 -*-
# @Time    : 2019/1/23 上午11:49

import easyGameTool.foreignTools.cocosPikachuTools.ExcelTools as et
import easyGameTool.projectConfig as cf
import os
import json
import pymysql
import shutil

resourceFile = cf.MACMINI_EGRET_STONE_PRO + "/resource"
allExmlFile = et.getFileName(resourceFile, ["exml"])


def getTableFormMysql(host, port, user, passwd, database, sqlStr):
    db = pymysql.connect(host=host,
                         port=port,
                         user=user,
                         passwd=passwd,
                         db=database)
    cursor = db.cursor()
    sql = sqlStr
    try:
        # 执行SQL语句
        cursor.execute(sql)
        # 获取所有记录列表
        results = cursor.fetchall()
        obj = []
        for row in results:
            itme = {}
            itme["Id"] = str(row[0])
Ejemplo n.º 16
0
# -*- coding: utf-8 -*-
# @Time    : 2019/2/20 下午8:20

import pymysql
from collections import OrderedDict
import os
import fileinput
import re
import xlrd
import xlwt

import easyGameTool.foreignTools.cocosPikachuTools.ExcelTools as et

allchilesexlsFile = et.getFileName(
    '/Users/admin/Documents/ljworkspace/local/egret/design/stone_age/RussianStone/peizhi',
    ["xls", "xlsx"], [])
for f in allchilesexlsFile:
    if not os.path.isfile(f.replace("xlsx", "xls")):
        et.copyfile(f, f.replace("xlsx", "xls"))

    fp, fn = os.path.split(f)
    ft = fn.split(".")[1]
    if ft == 'xlsx':
        os.remove(f)
# -*- coding: utf-8 -*-
# @Time    : 2019/2/28 下午4:46

# TODO 期望获取文件中的 中文  打到提取中文 并且替换中文 到新的 id 新的id  会insert 到 数据库里面  有点问题 !!!!!!
enFile = '/Users/admin/Documents/ljworkspace/local/cocos/project/pikachu_englishGit/pikachu_english/tools/pikachuCCB/ccb'  # /commons/EasyCommon.coffee

import easyGameTool.foreignTools.cocosPikachuTools.ExcelTools as et
import os
import copy

allCoffee = et.getFileName(enFile, ["ccb"], [])

ex = ["皮皮", '骄傲的老豆']  #皮?
allCoffeeData = None
allCoffeeData = et.processSql(
    "SELECT Id,Chinese from ccbTranslate WHERE Id IS NOT NULL and Id != 0")

insterSql = "INSERT INTO ccbTranslate (Id,Chinese, FilePth) VALUES ('{0}','{1}','{2}')"

insertCount = 0

needInsert = []


def getIdFormData(allData, chStr):
    for row in allData:
        if row[1] == chStr:
            print("id == > " + str(row[0]) + "  str = > " + row[1])
            return row[0]