diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Resources/LinuxStandardBaseUic.py	Thu Oct 22 16:17:10 2020 +0200
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+
+import subprocess
+import sys
+
+if len(sys.argv) <= 1:
+    sys.stderr.write('Please provide arguments for uic\n')
+    sys.exit(-1)
+
+path = ''
+pos = 1
+while pos < len(sys.argv):
+    if sys.argv[pos].startswith('-'):
+        pos += 2
+    else:
+        path = sys.argv[pos]
+        break
+
+if len(path) == 0:
+    sys.stderr.write('Unable to find the input file in the arguments to uic\n')
+    sys.exit(-1)
+
+with open(path, 'r') as f:
+    lines = f.read().split('\n')
+    if (len(lines) > 1 and
+        lines[0].startswith('<?')):
+        content = '\n'.join(lines[1:])
+    else:
+        content = '\n'.join(lines)
+        
+# Remove the source file from the arguments
+args = sys.argv[1:pos] + sys.argv[pos+1:]
+
+p = subprocess.Popen([ '/opt/lsb/bin/uic' ] + args,
+                     stdin = subprocess.PIPE)
+p.communicate(input = content)