瀏覽代碼

added a consistency checker and small bug fix in txtmerge

morgolon 9 年之前
父節點
當前提交
f6864a30d2
共有 2 個文件被更改,包括 32 次插入1 次删除
  1. 31 0
      check_consistency.py
  2. 1 1
      txtmerge.py

+ 31 - 0
check_consistency.py

@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# checks to make sure that glife.qproj is in sync with the location files
+
+import os
+import sys
+import re
+import io
+import xml.etree.ElementTree as ET
+import os.path
+
+# read the project xml file first
+tree = ET.parse('glife.qproj')
+root = tree.getroot()
+
+
+xml_locations = []
+os_locations = os.listdir("locations")
+
+print "Locations missing from ./locations/:"
+for location in root.iter('Location'):
+    name = location.attrib['name'].replace("$","_")
+    xml_locations.append(name)
+    
+    if name not in os_locations:
+        print name
+
+
+print "Locations missing from .qproj:"
+for name in os_locations:
+    if name not in xml_locations:
+        print name

+ 1 - 1
txtmerge.py

@@ -22,7 +22,7 @@ ofile = io.open(oname, 'w', encoding='utf-16', newline='\r\n')
 
 for location in root.iter('Location'):
     iname = location.attrib['name']
-    iname = iname.strip(' $')
+    iname = iname.replace("$","_")
 
     try:
         ifile = io.open(os.path.join(idir,iname), 'rt', encoding='utf-8')