Fix failing unrar test on windows (I hope)

This commit is contained in:
Kovid Goyal 2017-06-17 16:02:52 +05:30
parent ca7a11a289
commit 5d331a6c46
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -11,7 +11,7 @@ import shutil
import re
from io import BytesIO
from calibre.constants import filesystem_encoding
from calibre.constants import filesystem_encoding, iswindows
from calibre.ptempfile import PersistentTemporaryFile, TemporaryDirectory
@ -71,9 +71,13 @@ def comment(path_or_stream):
def extract_member(
path_or_stream, match=re.compile(r'\.(jpg|jpeg|gif|png)\s*$', re.I), name=None):
from unrardll import extract_member
if iswindows and name is not None:
name = name.replace(os.sep, '/')
def is_match(header):
fname = header['filename']
if iswindows:
fname = fname.replace(os.sep, '/')
return (name is not None and fname == name) or \
(match is not None and match.search(fname) is not None)