comparison Resources/CMake/LinuxStandardBaseUic.py @ 1041:95939fa925f6

LinuxStandardBaseUic.py
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 08 Oct 2019 17:23:27 +0200
parents
children
comparison
equal deleted inserted replaced
1040:14c0a29cd9ec 1041:95939fa925f6
1 #!/usr/bin/env python
2
3 import subprocess
4 import sys
5
6 if len(sys.argv) <= 1:
7 sys.stderr.write('Please provide arguments for uic\n')
8 sys.exit(-1)
9
10 path = ''
11 pos = 1
12 while pos < len(sys.argv):
13 if sys.argv[pos].startswith('-'):
14 pos += 2
15 else:
16 path = sys.argv[pos]
17 break
18
19 if len(path) == 0:
20 sys.stderr.write('Unable to find the input file in the arguments to uic\n')
21 sys.exit(-1)
22
23 with open(path, 'r') as f:
24 lines = f.read().split('\n')
25 if (len(lines) > 1 and
26 lines[0].startswith('<?')):
27 content = '\n'.join(lines[1:])
28 else:
29 content = '\n'.join(lines)
30
31 # Remove the source file from the arguments
32 args = sys.argv[1:pos] + sys.argv[pos+1:]
33
34 p = subprocess.Popen([ '/opt/lsb/bin/uic' ] + args,
35 stdin = subprocess.PIPE)
36 p.communicate(input = content)