Browse Source

really close, but need to escape the $ char somehow

morgolon 9 years ago
parent
commit
f430390c4d
1 changed files with 14 additions and 10 deletions
  1. 14 10
      txtmerge.py

+ 14 - 10
txtmerge.py

@@ -24,16 +24,20 @@ for location in root.iter('Location'):
     iname = location.attrib['name']
     iname = location.attrib['name']
     iname = iname.strip(' $')
     iname = iname.strip(' $')
 
 
-    ifile = io.open(os.path.join(idir,iname), 'rt', encoding='utf-8')
-    text = ifile.read()
-
-    # make sure there's a line at the end of file
-    # (why wouldn't there be one? WINDOWS!
-    if text[-1] != u'\n':
-        text += u'\n\n'
-
-    ofile.write(text)
-    ifile.close()
+    try:
+        ifile = io.open(os.path.join(idir,iname), 'rt', encoding='utf-8')
+        text = ifile.read()
+
+        # make sure there's a line at the end of file
+        # (why wouldn't there be one? WINDOWS!
+        if text[-1] != u'\n':
+            text += u'\n\n'
+
+        ofile.write(text)
+        ifile.close()
+    except IOError:
+        print "WARNING: missing location %s" % iname
+        pass
 
 
 ofile.close()
 ofile.close()