1#!/usr/bin/python3
2import subprocess
3import sys
4
5process = subprocess.Popen(['lint', '--check', 'UnusedResources', sys.argv[1]],
6                          stdout=subprocess.PIPE,
7                          stderr=subprocess.PIPE)
8
9stdout, stderr = process.communicate()
10
11lines = stdout.decode('utf-8').split('\n')
12results = []
13for i in range(len(lines)-1):
14    if '[UnusedResources]' in lines[i] and 'msgid=' not in lines[i+1]:
15        results.append(lines[i])
16
17if len(results) > 0:
18    print('\n'.join(results))
19    sys.exit(1)
20else:
21    sys.exit(0)
22
23