diff --git a/src/calibre/ebooks/lrf/html/convert_from.py b/src/calibre/ebooks/lrf/html/convert_from.py index be4feb2aeb..4bbf1fc53e 100644 --- a/src/calibre/ebooks/lrf/html/convert_from.py +++ b/src/calibre/ebooks/lrf/html/convert_from.py @@ -152,16 +152,16 @@ class HTMLConverter(object): (re.compile('
', re.IGNORECASE), lambda match : ' '), # Create header tags - (re.compile('<]*?id=BookTitle[^><]*?(align=)*(?(1)(\\w+))*[^><]*?>[^><]*?', re.IGNORECASE), + (re.compile(r'<]*?id=BookTitle[^><]*?(align=)*(?(1)(\w+))*[^><]*?>[^><]*?', re.IGNORECASE), lambda match : '

%s

'%(match.group(2) if match.group(2) else 'center', match.group(3))), - (re.compile('<]*?id=BookAuthor[^><]*?(align=)*(?(1)(\\w+))*[^><]*?>[^><]*?', re.IGNORECASE), + (re.compile(r'<]*?id=BookAuthor[^><]*?(align=)*(?(1)(\w+))*[^><]*?>[^><]*?', re.IGNORECASE), lambda match : '

%s

'%(match.group(2) if match.group(2) else 'center', match.group(3))), - (re.compile('<]*?id=title[^><]*?>(.*?)', re.IGNORECASE|re.DOTALL), + (re.compile(r'<]*?id=title[^><]*?>(.*?)', re.IGNORECASE|re.DOTALL), lambda match : '

%s

'%(match.group(1),)), - (re.compile('<]*?id=subtitle[^><]*?>(.*?)', re.IGNORECASE|re.DOTALL), + (re.compile(r'<]*?id=subtitle[^><]*?>(.*?)', re.IGNORECASE|re.DOTALL), lambda match : '

%s

'%(match.group(1),)), # Blank lines - (re.compile('<]*?>( ){4}', re.IGNORECASE), + (re.compile(r'<]*?>( ){4}', re.IGNORECASE), lambda match : '

'), ] @@ -403,7 +403,7 @@ class HTMLConverter(object): selector name and the value is a dictionary of properties """ sdict, pdict = {}, {} - style = re.sub('/\\*.*?\\*/', '', style) # Remove /*...*/ comments + style = re.sub(r'/\*.*?\*/', '', style) # Remove /*...*/ comments for sel in re.findall(HTMLConverter.SELECTOR_PAT, style): for key in sel[0].split(','): val = self.parse_style_properties(sel[1]) diff --git a/src/calibre/ebooks/lrf/pylrs/pylrf.py b/src/calibre/ebooks/lrf/pylrs/pylrf.py index 21bdb18afc..ba793e50ed 100644 --- a/src/calibre/ebooks/lrf/pylrs/pylrf.py +++ b/src/calibre/ebooks/lrf/pylrs/pylrf.py @@ -492,9 +492,8 @@ class LrfFileStream(LrfStreamBase): def __init__(self, streamFlags, filename): LrfStreamBase.__init__(self, streamFlags) - f = open(filename, "rb") - self.streamData = f.read() - f.close() + with open(filename, "rb") as f: + self.streamData = f.read() class LrfObject(object):