コード例 #1
0
ファイル: add_context.py プロジェクト: madsherp/mm678-i18n
def batchAddContext(inputPath, extension, encoding, outputPath,
                    filePathToContextFunc):
    for p in getFilePaths(inputPath, extension=extension):
        addContext(inputPath=p,
                   outputPath=outputPath.joinpath(p.relative_to(inputPath)),
                   encoding=encoding,
                   context=filePathToContextFunc(p))
コード例 #2
0
def batchValidateFilesEncoding(inputEncoding=None,
                               pathObj=Path('.'),
                               extension='txt',
                               outputEncoding=None):
    for p in getFilePaths(pathObj, extension=extension):
        print(p)
        validateFileEncoding(p, inputEncoding, outputEncoding)
コード例 #3
0
ファイル: convert_lf.py プロジェクト: madsherp/mm678-i18n
def batchConvertLf(inputPath,
                   outputPath,
                   SlashNTolf=True,
                   extension='txt',
                   encoding='UTF-8'):
    for p in getFilePaths(inputPath, extension=extension):
        convertLf(p, outputPath.joinpath(p.relative_to(inputPath)), encoding,
                  SlashNTolf)
コード例 #4
0
def copyFonts(d, pTemp, mmVersion, pNameCondensed):
	if mmVersion == '6':
		targetLod = 'icons'
	elif mmVersion == '7':
		targetLod = 'events'
	else: # 8 or merge
		targetLod = 'EnglishT'
	for fnt in getFilePaths(Path('non_text/font/' + d), 'fnt', False):
		shutil.copy(fnt, pTemp.joinpath('Data/10 Loc' + pNameCondensed + '.' + targetLod))
コード例 #5
0
def encodeDbcsSpecialFile(inputPath, outputPath, encoding):

    for p in getFilePaths(inputPath, ['txt', 'str', 'ini']):

        f = p.open(mode='rb')
        content = f.read()
        f.close()

        pout = outputPath.joinpath(p.relative_to(inputPath))
        pout.parent.mkdir(parents=True, exist_ok=True)
        fout = pout.open(mode='wb')
        fout.write(encodeDbcsSpecial(content, encoding))
        fout.close()
コード例 #6
0
ファイル: dbcs_special.py プロジェクト: jsho000/mm678-i18n
def decodeDbcsSpecialFile(inputPath, outputPath):

    inputPathTemp = Path(inputPath)
    outputPathTemp = Path(outputPath)

    for p in getFilePaths(inputPathTemp, ['txt', 'str', 'ini']):

        f = p.open(mode='rb')
        content = f.read()
        f.close()

        pout = outputPathTemp.joinpath(p.relative_to(inputPathTemp))
        pout.parent.mkdir(parents=True, exist_ok=True)
        fout = pout.open(mode='wb')
        fout.write(decodeDbcsSpecial(content))
        fout.close()
コード例 #7
0
def batchAddTransTemplate(inputPath, outputPath, extList='txt', skipRowDict={}):
	# extList can be one string or a list of strings
	filePathList = getFilePaths(inputPath, extList)

	# skipRowDict is a dictionary that contains
	# {file name : number of row to skip} pair
	# (if number of row to skip is 1, you don't need to specify here)
	skipRowFileNmeList = list(skipRowDict.keys())

	for filePath in filePathList:
		fileName = str(filePath)
		if fileName in skipRowFileNmeList:
			skipRow = skipRowDict[fileName]
		else:
			skipRow = 1
		addTransTemplate(filePath, skipRow, inputPath, outputPath)
コード例 #8
0
def testStrLineLengthInByte(inputPath,
                            extension,
                            maxLength,
                            newline='\n',
                            encoding='UTF-8',
                            encodingErrors="strict"):
    for p in getFilePaths(inputPath, extension):
        f = p.open(mode='r',
                   encoding=encoding,
                   newline=newline,
                   errors=encodingErrors)
        for n, line in enumerate(f):
            lineLen = len(line.encode(encoding))
            if lineLen > maxLength:
                print('Length of line ' + str(n + 1) + ' in file ' + str(p) +
                      ' is ' + str(lineLen) + ' and more than ' +
                      str(maxLength))
コード例 #9
0
def batchCheckLf(encoding=None, pathObj=Path('.'), extension='txt'):
    for p in getFilePaths(pathObj, extension=extension):
        checkLf(p, encoding)
コード例 #10
0
def copyFonts(d, pTemp, mmVersion, pNameCondensed):
	if mmVersion == '6':
		targetLod = 'icons'
	elif mmVersion == '7':
		targetLod = 'events'
	else: # 8 or merge
		targetLod = 'EnglishT'
	for fnt in getFilePaths(Path('non_text/font/' + d), 'fnt', False):
		shutil.copy(fnt, pTemp.joinpath('Data/10 Loc' + pNameCondensed + '.' + targetLod))


if Path('5_postprod').exists():
	shutil.rmtree('5_postprod')

for p in getFilePaths(Path('4_prod'), '', True):
	if p.name == 'nonprod' and p.exists():
		shutil.rmtree(p)

for p in getFilePaths(Path('4_prod'), '', False):
	if p.name in dbcsLangs:
		encodeDbcsSpecialFile(p, Path('5_postprod').joinpath(p.name), langEncDict[p.name])
	else:
		shutil.copytree(p, Path('5_postprod').joinpath(p.name))

# os.system('tools\\mmarch k non_text\scripts_datatables\mmmerge_rodril non_text\scripts_datatables\mmmerge filesonly non_text\scripts_datatables\difftemp')
# scriptDiffPath = Path('non_text/scripts_datatables/difftemp')

for p in getFilePaths(Path('5_postprod'), '', False):
	pTemp = p.joinpath('mm6/data/10LocLANG.icons')
	pNameCondensed = p.name.upper().replace('_', '') # e.g. ZHCN