py3: Ensure all builting recipes are in utf-8 and have the functions to get recipe code return unicode

This commit is contained in:
Kovid Goyal 2019-07-02 07:30:16 +05:30
parent 7c07d114ac
commit 8eac004f89
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 4 additions and 3 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python2
# -*- coding: latin-1 mode: python -*-
# -*- coding: utf-8 mode: python -*-
__license__ = 'GPL v3'
__copyright__ = '2009-2015, Darko Miletic <darko.miletic at gmail.com>'

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python2
# -*- coding: cp1252 -*-
# -*- coding: utf-8 -*-
__license__ = 'GPL v3'
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'

View File

@ -221,6 +221,7 @@ def download_builtin_recipe(urn):
import bz2
recipe_source = bz2.decompress(get_https_resource_securely(
'https://code.calibre-ebook.com/recipe-compressed/'+urn, headers={'CALIBRE-INSTALL-UUID':prefs['installation_uuid']}))
recipe_source = recipe_source.decode('utf-8')
from calibre.web.feeds.recipes import compile_recipe
recipe = compile_recipe(recipe_source) # ensure the downloaded recipe is at least compile-able
if recipe is None:
@ -232,7 +233,7 @@ def download_builtin_recipe(urn):
def get_builtin_recipe(urn):
with zipfile.ZipFile(P('builtin_recipes.zip', allow_user_override=False), 'r') as zf:
return zf.read(urn+'.recipe')
return zf.read(urn+'.recipe').decode('utf-8')
def get_builtin_recipe_by_title(title, log=None, download_recipe=False):