Commits

Anonymous committed ca6566e

be more roboust when merging rc files

Comments (0)

Files changed (1)

 
 def read_utf8(path):
     '''
-    Reads an utf-8-sig encoded file and returns it contents.
+    Reads an utf-8-sig encoded file and returns its contents.
 
     @type path: str
     @param path: The file path.
     '''
     Writes the specified lines to the specied file.
 
-    The file is encoded as UTF8 without signature to avoid problems with
+    The file is encoded as UTF-8 without signature to avoid problems with
     Mercurial (which does not seem to handle signatures).
 
     @type path: str
     file(path, 'wb').write(data.encode('utf-8'))
 
 def merge_into_rc_file(path, sectionname, hook):
-    lines = [ l.decode('utf-8-sig').strip() for l in file(path).xreadlines() ]
-    if not lines: # TODO: Er denne ikke overflødig?
-        lines = []
-
+    lines = [l.strip() for l in tounicode(file(path).read()).split('\n')]
     insection = False
     wassection = False
     out = []