-
Notifications
You must be signed in to change notification settings - Fork 2
/
xlationlint.py
39 lines (35 loc) · 1.12 KB
/
xlationlint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
import sys
import json
import os
import subprocess
import re
try:
# For python3
import urllib.request
except ImportError:
# For python2
import imp
import urllib2
urllib = imp.new_module('urllib')
urllib.request = urllib2
for change in sys.argv[1:]:
print(change)
f = urllib.request.urlopen('http://review.cyanogenmod.org/query?q=change:%s' % change)
d = f.read().decode()
# gerrit doesnt actually return json. returns two json blobs, separate lines. bizarre.
d = d.split('\n')[0]
data = json.loads(d)
project = data['project']
plist = subprocess.Popen([os.environ['HOME']+"/bin/repo","list"], stdout=subprocess.PIPE)
while(True):
retcode = plist.poll()
pline = plist.stdout.readline().rstrip()
ppaths = re.split('\s*:\s*', pline.decode())
if ppaths[1] == project:
project = ppaths[0]
break
if(retcode is not None):
break
retval = os.system('cd %s ; xmllint --noout `git show FETCH_HEAD | grep "^+++ b" | sed -e \'s/^+++ b\///g\' | egrep "res/.*xml$"`' % (project))
sys.exit(retval!=0)