doclib/fix-links: open files in utf-8 mode
tho [Tue, 25 Aug 2009 16:19:33 +0000 (16:19 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1337 270642c3-0616-0410-b53a-bc976706d245

doclib/fix-links.py

index 2fe5db6..fb7450e 100644 (file)
@@ -26,7 +26,7 @@
 # index. Doxygen seems to create links with the wrong number of 'g'
 # charachters in front sometimes.
 
-import sys,os.path,fnmatch, HTMLParser, getopt, re
+import sys,os.path,fnmatch, HTMLParser, getopt, re, codecs
 
 class HTMLFilter(HTMLParser.HTMLParser):
 
@@ -213,11 +213,11 @@ class LinkFixer:
 
     def fix(self, path, target):
         self._files += 1
-        data = file(path).read()
+        data = codecs.open(path, "r", "utf-8").read()
         filt = LinkFixer.LinkFilter(self._index,
                                     target,
                                     "../" * (len(os.path.split(path)[0].split("/"))),
-                                    file(path,"w"))
+                                    codecs.open(path, "w", "utf-8") )
         filt.feed(data)
         filt.close()
         found, fixed, removed = filt.stats()