Back to index

plone3  3.1.7
sync.py
Go to the documentation of this file.
00001 """
00002    Usage: sync.py [<product> | <language-code>]
00003 """
00004 
00005 import os, sys
00006 from utils import getPoFilesAsCmdLine, getPoFilesByLanguageCode, getProduct, getPotFiles, getLongProductName
00007 
00008 __I18NDUDE = os.environ.get('I18NDUDE', 'i18ndude')
00009 
00010 def main():
00011     if len(sys.argv) == 1:
00012         print 'You have to specify a product or a language code.'
00013         sys.exit(1)
00014 
00015     product = getLongProductName(sys.argv[1])
00016     pot = '%s.pot' % product
00017 
00018     os.chdir('..')
00019     os.chdir('i18n')
00020 
00021     if not os.path.isfile(pot): # no pot? test for language-code
00022         poFiles = getPoFilesByLanguageCode(product)
00023         if poFiles:
00024             potFiles = getPotFiles()
00025             for po in poFiles:
00026                 for pot in potFiles:
00027                     if getProduct(po) == getProduct(pot):
00028                         os.system(__I18NDUDE + (' sync --pot %s %s') % (pot, po))
00029         else:
00030             print 'Neither a pot nor po files for the given argument were found.'
00031             sys.exit(3)
00032 
00033     else: # product was given
00034         poFiles = getPoFilesAsCmdLine(product)
00035         if poFiles == []:
00036             print 'No po-files were found for the given product.'
00037             sys.exit(4)
00038 
00039         os.system(__I18NDUDE + (' sync --pot %s %s') % (pot, poFiles))
00040 
00041 if __name__ == '__main__':
00042     main()