Parcourir la source

added a consistency checker and small bug fix in txtmerge

morgolon il y a 9 ans
Parent
commit
f6864a30d2
2 fichiers modifiés avec 32 ajouts et 1 suppressions
  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')