Fix #4683 (If comics.txt is UTF-8 with a byte order mark, the first comic is skipped)

This commit is contained in:
Kovid Goyal 2010-01-29 11:22:30 -07:00
parent 37c90afed4
commit 79bb3ba005

View file

@ -7,7 +7,7 @@
Based on ideas from comiclrf created by FangornUK.
'''
import os, shutil, traceback, textwrap, time
import os, shutil, traceback, textwrap, time, codecs
from ctypes import byref
from Queue import Empty
@ -338,8 +338,9 @@ def get_comics_from_collection(self, stream):
if not os.path.exists('comics.txt'):
raise ValueError('%s is not a valid comic collection'
%stream.name)
for line in open('comics.txt',
'rb').read().decode('utf-8').splitlines():
raw = open('comics.txt', 'rb').read().decode('utf-8')
raw.lstrip(unicode(codecs.BOM_UTF8, "utf8" ))
for line in raw.splitlines():
line = line.strip()
if not line:
continue