def process(csvFileName): (contentsMapList, keyLists, pathList, dstLangList, baselineLang) = csvUtil.generateContentsMapListFromCSVFile( csvFileName ) for i in range(0, len(contentsMapList)): contentsMap = contentsMapList[i] baselineName = pathList[i] print "Processing: " + baselineName for j in range(0, len(dstLangList)): dstLang = dstLangList[j] (flag, dstFileName) = fileUtil.getDstXMLFileNameFromBaselineXMLFileName(baselineName, dstLang) dstFile = open(dstFileName + SUFFIX_TMP, "wb") xmlUtil.writeBackDstXMLFile(contentsMap, j + 1, dstFile, baselineName) keepSpecialChars(dstFileName + SUFFIX_TMP, dstFileName) print "Destination file : " + dstFileName + " is updated."
def process(csvFileName): (contentsMapList, keyLists, pathList, dstLangList, baselineLang) = csvUtil.generateContentsMapListFromCSVFile(csvFileName) for i in range(0, len(contentsMapList)): contentsMap = contentsMapList[i] baselineName = pathList[i] print "Processing: " + baselineName for j in range(0, len(dstLangList)): dstLang = dstLangList[j] (flag, dstFileName) = fileUtil.getDstXMLFileNameFromBaselineXMLFileName( baselineName, dstLang) dstFile = open(dstFileName + SUFFIX_TMP, 'wb') xmlUtil.writeBackDstXMLFile(contentsMap, j + 1, dstFile, baselineName) keepSpecialChars(dstFileName + SUFFIX_TMP, dstFileName) print "Destination file : " + dstFileName + " is updated."
print "IOError: " + strerror print "Output file: '" + outputFileName + "' invalid" return #tell excel UTF-8 is used outFile.write(codecs.BOM_UTF8) writer = csv.writer(outFile) csvUtil.writeFirstRow(baselineLang, dstLangList, writer) for path in pathList: baselineFileNameList = [] fileUtil.getBaselineXMLFileNameListFromSearchPath(baselineLang, path, baselineFileNameList) for filename in baselineFileNameList: print "Processing: " + filename (contentsMap, keyList) = xmlUtil.generateBaseLineContentsMapFromXMLFile(filename, len(dstLangList)) for i in range(0, len(dstLangList)): dstLang = dstLangList[i] (flag, fileNameDst) = fileUtil.getDstXMLFileNameFromBaselineXMLFileName(filename, dstLang) if flag:#means that the dst language strings.xml exists result = xmlUtil.generateDstContentsIntoContentsMapFromXMLFile(contentsMap, fileNameDst, i+1) if result: bakFileList.append(fileNameDst) csvUtil.writeCsvContentRows(keyList, contentsMap, writer, filename, dstLangList) print "CSV file " + outputFileName + " is generated." backupFileList(bakFileList, bakFileName) print "Backup file " + bakFileName + " is generated." if __name__ == "__main__": reload(sys) sys.setdefaultencoding(CHARSET) parser = optparse.OptionParser( usage = "python generateCSV.py <config file>\n" + "config file format:\n"