1
0
Ver Fonte

Created script to merge all location files

alecsp há 2 anos atrás
pai
commit
d6a2092c6c
1 ficheiros alterados com 33 adições e 0 exclusões
  1. 33 0
      tools/txtmerge-all.py

+ 33 - 0
tools/txtmerge-all.py

@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+# usage: txtmerge-all.py <input_dir> <output_file_name> 
+# does the exact opposite of txtsplit.py
+
+import os
+import sys
+import re
+import io
+import glob
+import shutil
+
+assert len(sys.argv) == 3, "usage:\ntxtmerge-all.py <input_dir> <output_file_name>"
+idir = str(sys.argv[1])
+oname = str(sys.argv[2])
+startLocationPath = os.path.join(idir, 'start.qsrc')
+
+with io.open(oname, 'w', encoding='utf-16', newline='\r\n') as ofile:
+    with io.open(startLocationPath, 'rt', encoding='utf-8') as ifile:
+        shutil.copyfileobj(ifile, ofile)
+    for location in glob.glob(os.path.join(idir, '*.qsrc')):
+        if location != startLocationPath:
+            with io.open(location, 'rt', encoding='utf-8') as ifile:
+                shutil.copyfileobj(ifile, ofile)
+    from datetime import date
+    from sys import version_info
+    ofile.write(u"#addbuilddate" + '\n')
+    today = date.today()
+    if version_info.major == 2:
+        du = unicode(today.strftime("$builddate = '%B %d, %Y'"), 'utf8') + '\n'
+    elif version_info.major == 3:
+        du = str(today.strftime("$builddate = '%B %d, %Y'")) + '\n'
+    ofile.write(du)
+    ofile.write(u"--- addbuilddate ---------------------------------" + '\n')