blob: 6472b4c0d5990bbbcf3860421ae8c327578ef7e2 [file] [log] [blame]
Marco Brohetf9d4a5b2014-02-27 15:02:24 +01001#!/usr/bin/python2
2
3import os.path
4import sys
5import cm_sync
6from urllib import urlretrieve
7from subprocess import call
8from xml.dom import minidom
9
10print('STEP 0: Welcome to the CM Crowdin sync script\n')
11
12print('STEP 1: Create cm_caf.xml')
13
14if not os.path.isfile('caf.xml'):
15 sys.exit('You have no caf.xml. Terminating')
16xml = minidom.parse('caf.xml')
17items = xml.getElementsByTagName('item')
18
19cm_caf = []
20
21for item in items:
22 call(['mkdir', '-p', 'tmp/' + item.attributes["path"].value])
23 item_aosp = item.getElementsByTagName('aosp')
24 for aosp_item in item_aosp:
25 url = aosp_item.firstChild.nodeValue
26 path_to_base = 'tmp/' + item.attributes["path"].value + '/' + aosp_item.attributes["file"].value
27 path_to_cm = item.attributes["path"].value + '/' + aosp_item.attributes["file"].value
28 path = item.attributes["path"].value
29 urlretrieve(url, path_to_base)
30 cm_sync.create_cm_caf_xml(path_to_base, path_to_cm, path)
31 cm_caf.append(path + '/cm_caf.xml')
32
33print('\nSTEP 2: Upload Crowdin source translations')
34
35print('\nSTEP 3: Clean up')
36for cm_caf_file in cm_caf:
37 print ('Removing ' + cm_caf_file)
38 os.remove(cm_caf_file)
39
40print('\nSTEP 4: Done!')