dont fail if reading metadata.opf fails

This commit is contained in:
j 2015-12-08 11:54:04 +00:00
parent 58541fa303
commit fe7769a7ba

View file

@ -10,10 +10,17 @@ from utils import normalize_isbn
from ox import strip_tags from ox import strip_tags
import ox.iso import ox.iso
import logging
logger = logging.getLogger(__name__)
def info(opf): def info(opf):
data = {} data = {}
with open(opf) as fd: try:
opf = ET.fromstring(fd.read()) with open(opf, 'rb') as fd:
opf = ET.fromstring(fd.read().decode())
except:
logger.debug('failed to load opf %s', opf, exc_info=1)
return data
ns = '{http://www.idpf.org/2007/opf}' ns = '{http://www.idpf.org/2007/opf}'
metadata = opf.findall(ns + 'metadata')[0] metadata = opf.findall(ns + 'metadata')[0]
for e in metadata.getchildren(): for e in metadata.getchildren():