comparison Applications/Resources/LinuxStandardBaseUic.py @ 1586:b5417e377636

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 22 Oct 2020 16:17:10 +0200
parents OrthancStone/Resources/CMake/LinuxStandardBaseUic.py@244ad1e4e76a
children 8c5f9864545f
comparison
equal deleted inserted replaced
1585:94edbfa64c97 1586:b5417e377636
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)