Exemplo n.º 1
0
    print "Downloaded to", zipPath[0]

    #Extract to /tmp/Crowdin
    zip = ZipFile(zipPath[0])
    extractDir = os.path.join(os.path.dirname(zipPath[0]), "Crowdin")
    zip.extractall(extractDir)
    print "Extracted to", extractDir

    print "Attempting to match Crowdin files with Android"
    #Get valid Crowdin folder mappings
    crowdinMappings = helper.GetCrowdinMappings(extractDir)

    #Get list of files to copy
    isSingleFolderUpdate = helper.IsSingleFolderUpdate(options.path)
    matchingFiles = helper.GetMatchingCrowdinFiles(languageCodes,
                                                   crowdinMappings,
                                                   not isSingleFolderUpdate)

    #Get res directory
    targetResDirectory = helper.GetResDirectory(options.path)

    #Copy the files
    if not len(matchingFiles):
        print "No matching files found"

    for k, v in matchingFiles.iteritems():
        targetStringsXml = helper.GetTargetStringsXml(targetResDirectory, k)

        if not os.path.exists(os.path.dirname(targetStringsXml)):
            os.makedirs(os.path.dirname(targetStringsXml))
Exemplo n.º 2
0
 def test_GetMatchingCrowdinFiles_DifferentNarrowScope_ReturnsPathToDifferentNarrowScope(self):
     lc = ['en', 'fr', 'pt', 'es']
     cm = {'fr':'/french', 'pt-PT' : '/narrowPortuguese', 'es-MX' : '/mexicanPath'}
     matches = helper.GetMatchingCrowdinFiles(lc, cm)
     self.assertEqual(matches['es'], '/mexicanPath')
Exemplo n.º 3
0
 def test_GetMatchingCrowdinFiles_NotInLanguageCodeButNarrowerScopeThanExisting_RemovesMatchedNarrow(self):
     lc = ['de']
     cm = { 'de-NL' : '/Netherlands', 'de-MX': '/Mexico'}
     matches = helper.GetMatchingCrowdinFiles(lc, cm)
     self.assertEqual(matches['de'], '/Mexico')
     self.assertTrue('de-MX' not in matches)
Exemplo n.º 4
0
 def test_GetMatchingCrowdinFiles_NarrowScopeMatchedFirst(self):
     lc = {'zh-TW' , 'zh'}
     cm = {  'zh-TW':'/zhtwPath', 'zh-CN': '/zhcnPath'   }
     matches = helper.GetMatchingCrowdinFiles(lc,cm, True)
     self.assertEqual('/zhcnPath', matches['zh'])
Exemplo n.º 5
0
 def test_GetMatchingCrowdinFiles_NoWideScopedLanguageCode_ReturnsPathToNarrowScope(self):
     lc = ['en', 'fr', 'pt']
     cm = {'fr':'/french', 'pt-PT' : '/narrowPortuguese'}
     matches = helper.GetMatchingCrowdinFiles(lc, cm)
     self.assertEqual(matches['pt'], '/narrowPortuguese')
Exemplo n.º 6
0
 def test_GetMatchingCrowdinFiles_NonMatchingEnglish_NotReturnedInDictionary(self):
     lc = ['en', 'fr', 'sv-SE']
     cm = {'fr':'/french'}
     matches = helper.GetMatchingCrowdinFiles(lc, cm)
     self.assertTrue('en' not in matches)
Exemplo n.º 7
0
 def test_GetMatchingCrowdinFiles_MatchingFrench_ReturnsPathToFrenchFile(self):
     lc = ['en', 'fr', 'sv-SE']
     cm = {'fr':'/french'}
     matches = helper.GetMatchingCrowdinFiles(lc, cm)
     self.assertEqual(matches['fr'], "/french")
Exemplo n.º 8
0
 def test_GetMatchingCrowdinFiles_IncludeNewFolders_ReturnsNewFolders(self):
     lc = ['de']
     cm = { 'de-NL' : '/Netherlands', 'de-MX': '/Mexico'}
     matches = helper.GetMatchingCrowdinFiles(lc, cm, True)
     self.assertEqual(matches['de'], '/Mexico')
     self.assertTrue('de-NL' in matches)