Ver código fonte

really close, but need to escape the $ char somehow

morgolon 9 anos atrás
pai
commit
f430390c4d
1 arquivos alterados com 14 adições e 10 exclusões
  1. 14 10
      txtmerge.py

+ 14 - 10
txtmerge.py

@@ -24,16 +24,20 @@ for location in root.iter('Location'):
     iname = location.attrib['name']
     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()