def updateLocale(localeDir, remove, rename):
    for source, target in rename.iteritems():
        sourceFile, sourceKey = source.split(' ', 1)
        targetFile, targetKey = target.split(' ', 1)

        sourceFile = os.path.join(localeDir, sourceFile)
        targetFile = os.path.join(localeDir, targetFile)
        if not os.path.exists(sourceFile):
            continue

        sourceData = localeTools.readFile(sourceFile)
        if sourceKey in sourceData:
            localeTools.appendToFile(targetFile, targetKey,
                                     sourceData[sourceKey])
        localeTools.removeFromFile(sourceFile, sourceKey)

    for entry in remove:
        if ' ' in entry:
            file, key = entry.split(' ', 1)
            file = os.path.join(localeDir, file)
            if os.path.exists(file):
                localeTools.removeFromFile(file, key)
        else:
            file = os.path.join(localeDir, entry)
            if os.path.exists(file):
                os.remove(file)
Beispiel #2
0
def updateLocale(localeDir, remove, rename):
  for source, target in rename.iteritems():
    sourceFile, sourceKey = source.split(' ', 1)
    targetFile, targetKey = target.split(' ', 1)

    sourceFile = os.path.join(localeDir, sourceFile)
    targetFile = os.path.join(localeDir, targetFile)
    if not os.path.exists(sourceFile):
      continue

    sourceData = localeTools.readFile(sourceFile)
    if sourceKey in sourceData:
      localeTools.appendToFile(targetFile, targetKey, sourceData[sourceKey])
    localeTools.removeFromFile(sourceFile, sourceKey)

  for entry in remove:
    if ' ' in entry:
      file, key = entry.split(' ', 1)
      file = os.path.join(localeDir, file)
      if os.path.exists(file):
        localeTools.removeFromFile(file, key)
    else:
      file = os.path.join(localeDir, entry)
      if os.path.exists(file):
        os.remove(file)