Esempio n. 1
0
    def gettext(self, gettext):
        if self.conf.is_windows:
            gt = Gettext(True, self.conf.getExe('gettext'))
        else:
            gt = Gettext()
        po_file = self.conf.getClientPath("i18n", self.args.lang + '.po')
        mo_file = self.conf.getClientPath("res", self.args.lang)
        if not os.path.exists(po_file):
            slog.error('CANNOT find the po file: [%s]!' % po_file)
            return

        if gettext == 'mo':
            print_sep('\nStart to convert [%s] to [%s].' % (po_file, mo_file),
                      True, 40)
            gt.fmt(po_file, mo_file)
            print_sep('Converting PO to MO has done.', False, 40)
        else:
            # Include (game/login/conf/root)
            lua_files = list(get_files(self.conf.getClientPath('src', 'conf'), ext=['.lua'])) + \
                list(get_files(self.conf.getClientPath('src', 'game'), ext=['.lua'])) + \
                list(get_files(self.conf.getClientPath('src', 'login'), ext=['.lua'])) + \
                list(get_files(self.conf.getClientPath('src', 'root'), ext=['.lua']))
            print_sep('\nStart to merge new translatations to [%s].' % po_file,
                      True, 40)
            gt.merge(po_file, lua_files)
            print_sep('Merging has done.', False, 40)
Esempio n. 2
0
def call(xls, export, tmpl, command=[], ptype="all"):
    if not os.path.exists(xls):
        raise ParseError("xls directory is not exists:" + xls)
    if not os.path.exists(export):
        raise ParseError("export directory is not exists:" + export)
    if not os.path.exists(tmpl):
        raise ParseError("tmpl directory is not exists:" + tmpl)

    dirconf.updateXlsPath(xls)
    dirconf.updateTempPath(tmpl)

    if ptype == "all":
        dirconf.updateExportPath(export)
    elif ptype == "lua":
        dirconf.updateLuaPath(export)
    elif ptype == "csv":
        dirconf.updateCsvPath(export)

    files = filter(excludeFiles, get_files(dirconf.xls_path, ["py"]))

    if isinstance(command, list) and len(command) != 0:
        files = get_theModule(files, command)  # + ".py"

    parser = Parser(ptype)
    parser.parseModules(files)
Esempio n. 3
0
def call(xls, export, tmpl, command=[], ptype="all"):
    if not os.path.exists(xls):
        raise ParseError("xls directory is not exists:" + xls)
    if not os.path.exists(export):
        raise ParseError("export directory is not exists:" + export)
    if not os.path.exists(tmpl):
        raise ParseError("tmpl directory is not exists:" + tmpl)

    dirconf.updateXlsPath(xls)
    dirconf.updateTempPath(tmpl)

    if ptype == "all":
        dirconf.updateExportPath(export)
    elif ptype == "lua":
        dirconf.updateLuaPath(export)
    elif ptype == "csv":
        dirconf.updateCsvPath(export)

    files = filter(excludeFiles, get_files(dirconf.xls_path, ["py"]))

    if isinstance(command, list) and len(command) != 0:
        files = get_theModule(files, command)  # + ".py"

    parser = Parser(ptype)
    parser.parseModules(files)
Esempio n. 4
0
def call(heroPath, sszPath, exportPath):
    parser = Parser(exportPath)

    # parse heros
    files = filter(herosFiles, get_files(heroPath, ["json"]))
    slog.info("parse: etc.json")
    parser.parseHero(files)

    # parse ssz
    files = filter(confFiles, get_files(sszPath, ["json"]))
    for path in files:
        slog.info("parse: %s", os.path.basename(path))
        jsontxt = read_file(path)
        jsontxt = re.sub(r'\/\/.*$', '', jsontxt, flags=re.M)
        obj = json.loads(jsontxt)
        parser.parseConf(obj, os.path.basename(path).split('.')[0])
Esempio n. 5
0
def call(heroPath, sszPath, exportPath):
    parser = Parser(exportPath)
    #parse tmpl
    parser.parseTmpl(heroPath)

    # parse heros
    files = filter(herosFiles, get_files(heroPath, ["json"]))
    slog.info("parse: etc.json")
    parser.parseHero(files)

    # parse ssz
    files = filter(confFiles, get_files(sszPath, ["json"]))
    for path in files:
        slog.info("parse: %s", os.path.basename(path))
        jsontxt = read_file(path)
        jsontxt = re.sub(r'\/\/.*$', '', jsontxt, flags=re.M)
        obj = json.loads(jsontxt)
        parser.parseConf(obj, os.path.basename(path).split('.')[0])
Esempio n. 6
0
 def _run_dir(self, dirname):
     dirpath = self.conf.getClientPath('res', dirname)
     files = get_files(dirpath, ['png'])
     filterfiles = []
     for f in files:
         if os.path.getsize(f) > self.file_size:
             filterfiles.append(f)
     for f in filterfiles:
         xargs = self._get_param(f, f)
         #slog.info(xargs)
         subprocess.call(xargs)
Esempio n. 7
0
File: res.py Progetto: team1201/tbbl
    def gettext(self, gettext):
        if self.conf.is_windows:
            gt = Gettext(True, self.conf.getExe('gettext'))
        else:
            gt = Gettext()
        po_file = self.conf.getClientPath("i18n", self.args.lang+'.po')
        mo_file = self.conf.getClientPath("res", self.args.lang)
        if not os.path.exists(po_file):
            slog.error('CANNOT find the po file: [%s]!'%po_file)
            return

        if gettext == 'mo':
            print_sep('\nStart to convert [%s] to [%s].'%(po_file, mo_file), True, 40)
            gt.fmt(po_file, mo_file)
            print_sep('Converting PO to MO has done.', False, 40)
        else:
            # Include (game/login/conf/root)
            lua_files = list(get_files(self.conf.getClientPath('src', 'conf'), ext=['.lua'])) + \
                list(get_files(self.conf.getClientPath('src', 'game'), ext=['.lua'])) + \
                list(get_files(self.conf.getClientPath('src', 'login'), ext=['.lua'])) + \
                list(get_files(self.conf.getClientPath('src', 'root'), ext=['.lua']))
            print_sep('\nStart to merge new translatations to [%s].'%po_file, True, 40)
            gt.merge(po_file, lua_files)
            print_sep('Merging has done.', False, 40)
Esempio n. 8
0
def test_merge():
    lua_files = list(get_files(src, ext=['.lua']))
    po_file = os.path.join(workdir, 'zh_cn.po')
    gt.merge(po_file, lua_files)
Esempio n. 9
0
def test_get_files():
    assert len(list(base.get_files(workDir))) > 0
Esempio n. 10
0
def test_get_files():
    assert len(list(base.get_files(workDir))) > 0
Esempio n. 11
0
def test_merge():
    lua_files = list(get_files(src, ext=['.lua']))
    po_file = os.path.join(workdir, 'zh_cn.po')
    gt.merge(po_file, lua_files)