This commit is contained in:
Kovid Goyal 2008-03-13 01:57:33 +00:00
parent 46fee39026
commit 04ca5c26b4

View File

@ -1801,9 +1801,14 @@ def try_opf(path, options, logger):
if hasattr(options, 'opf'): if hasattr(options, 'opf'):
opf = options.opf opf = options.opf
else: else:
try: files = glob.glob(os.path.join(os.path.dirname(path),'*'))
opf = glob.glob(os.path.join(os.path.dirname(path),'*.opf'))[0] opf = None
except IndexError: for f in files:
ext = f.rpartition('.')[-1].lower()
if ext == 'opf':
opf = f
break
if opf is None:
return return
dirpath = os.path.dirname(os.path.abspath(opf)) dirpath = os.path.dirname(os.path.abspath(opf))
opf = OPFReader(open(opf, 'rb'), dirpath) opf = OPFReader(open(opf, 'rb'), dirpath)