From 53f30d9b7f1fd6cfb0971c2bf5f0e233ea4df062 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 30 Oct 2019 10:34:50 -0400 Subject: [PATCH] linux install: make file blobs start as unicode and get encoded while writing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kovid wants to be cautious about future refactoring maybe trying to modify them, and would prefer Thingsā„¢ be unicode for flexibility when using them, and only be bytes when actually write()'ing them. See https://github.com/kovidgoyal/calibre/pull/1065#issuecomment-547893895 --- src/calibre/linux.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/calibre/linux.py b/src/calibre/linux.py index b7d30caa65..c37c15ab0c 100644 --- a/src/calibre/linux.py +++ b/src/calibre/linux.py @@ -866,16 +866,16 @@ class PostInstall: from calibre.ebooks.oeb.polish.main import SUPPORTED from calibre.ebooks.oeb.polish.import_book import IMPORTABLE with open('calibre-lrfviewer.desktop', 'wb') as f: - f.write(VIEWER) + f.write(VIEWER.encode('utf-8')) with open('calibre-ebook-viewer.desktop', 'wb') as f: - f.write(EVIEWER) + f.write(EVIEWER.encode('utf-8')) write_mimetypes(f) with open('calibre-ebook-edit.desktop', 'wb') as f: - f.write(ETWEAK) + f.write(ETWEAK.encode('utf-8')) mt = {guess_type('a.' + x.lower())[0] for x in (SUPPORTED|IMPORTABLE)} - {None, 'application/octet-stream'} f.write(('MimeType=%s;\n'%';'.join(mt)).encode('utf-8')) with open('calibre-gui.desktop', 'wb') as f: - f.write(GUI) + f.write(GUI.encode('utf-8')) write_mimetypes(f) des = ('calibre-gui.desktop', 'calibre-lrfviewer.desktop', 'calibre-ebook-viewer.desktop', 'calibre-ebook-edit.desktop') @@ -1029,7 +1029,7 @@ complete -o filenames -F _'''%dict(pics=spics, opts=opts, extras=extras, exts=exts) + fname + ' ' + name +"\n\n").encode('utf-8') -VIEWER = b'''\ +VIEWER = '''\ [Desktop Entry] Version=1.0 Type=Application @@ -1043,7 +1043,7 @@ MimeType=application/x-sony-bbeb; Categories=Graphics;Viewer; ''' -EVIEWER = b'''\ +EVIEWER = '''\ [Desktop Entry] Version=1.0 Type=Application @@ -1056,7 +1056,7 @@ Icon=calibre-viewer Categories=Graphics;Viewer; ''' -ETWEAK = b'''\ +ETWEAK = '''\ [Desktop Entry] Version=1.0 Type=Application @@ -1069,7 +1069,7 @@ Icon=calibre-ebook-edit Categories=Office; ''' -GUI = b'''\ +GUI = '''\ [Desktop Entry] Version=1.0 Type=Application