mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #446
This commit is contained in:
parent
46fee39026
commit
04ca5c26b4
@ -1801,9 +1801,14 @@ def try_opf(path, options, logger):
|
||||
if hasattr(options, 'opf'):
|
||||
opf = options.opf
|
||||
else:
|
||||
try:
|
||||
opf = glob.glob(os.path.join(os.path.dirname(path),'*.opf'))[0]
|
||||
except IndexError:
|
||||
files = glob.glob(os.path.join(os.path.dirname(path),'*'))
|
||||
opf = None
|
||||
for f in files:
|
||||
ext = f.rpartition('.')[-1].lower()
|
||||
if ext == 'opf':
|
||||
opf = f
|
||||
break
|
||||
if opf is None:
|
||||
return
|
||||
dirpath = os.path.dirname(os.path.abspath(opf))
|
||||
opf = OPFReader(open(opf, 'rb'), dirpath)
|
||||
|
Loading…
x
Reference in New Issue
Block a user