Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hacker <dd0t@users.sourceforge.net>2015-06-21 19:57:20 +0300
committerStefan Hacker <dd0t@users.sourceforge.net>2015-07-12 02:15:33 +0300
commit65c1affbdcf293a8445c378cc4fdb2ea0e07fbd5 (patch)
treed2b02b92538bf58bffa80df79a678606c2d1ae7d /scripts/generate-qrc.py
parent83b6071597a655831c316dd80f548d121be437f5 (diff)
Add generate-qrc.py script as a rcc -project replacement
One can use rcc -project to emit .qrc files for the contents of a directory. However this functionality seems to be woefully incomplete to the point of being broken. This small python script offers the same functionality with more options to customize and configure behaviour. This includes custom prefixes, better handling of qrc file path vs. alias and exclusions.
Diffstat (limited to 'scripts/generate-qrc.py')
-rwxr-xr-xscripts/generate-qrc.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/generate-qrc.py b/scripts/generate-qrc.py
new file mode 100755
index 000000000..93373e611
--- /dev/null
+++ b/scripts/generate-qrc.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+
+#
+# Improved version of rcc --project
+#
+import sys
+import os
+import re
+import argparse
+
+parser = argparse.ArgumentParser(description='Improved version of rcc --project')
+parser.add_argument('theme')
+parser.add_argument('--cwd', default='.')
+parser.add_argument('--prefix', default='')
+parser.add_argument('--output', '-o')
+parser.add_argument('--include', '-i', default='.*', help='Default inclusion regex')
+parser.add_argument('--exclude', '-e', default='a^', help='Default exclusion regex')
+
+args = parser.parse_args()
+
+out = sys.stdout
+if args.output:
+ out = open(args.output, 'w')
+
+print>>out, '<!DOCTYPE RCC>'
+print>>out, '<RCC version=\"1.0\">'
+print>>out, '<qresource prefix="%s">' % args.prefix
+
+include = re.compile(args.include)
+exclude = re.compile(args.exclude)
+
+os.chdir(args.cwd)
+for (dirpath, dirnames, filenames) in os.walk(args.theme):
+ for f in filenames:
+ path = os.path.join(dirpath, f)
+ relpath = os.path.relpath(path, args.theme)
+
+ if not include.search(relpath):
+ continue
+
+ if exclude.search(relpath):
+ continue
+
+ print>>out, ' <file alias="%s">%s</file>' % (relpath, path)
+print>>out, '</qresource>'
+print>>out, '</RCC>'