Blame 0001-a2x-Write-manifests-in-UTF-8-by-default.patch
|
Stanislav Ochotnicky |
395a42 |
From adb0929f0db4da533a9d5b317e6f49a91feb3b3e Mon Sep 17 00:00:00 2001
|
|
Stanislav Ochotnicky |
395a42 |
From: Stanislav Ochotnicky <sochotnicky@redhat.com>
|
|
Stanislav Ochotnicky |
395a42 |
Date: Tue, 3 Dec 2013 18:03:13 +0100
|
|
Stanislav Ochotnicky |
395a42 |
Subject: [PATCH] [a2x] Write manifests in UTF-8 by default
|
|
Stanislav Ochotnicky |
395a42 |
|
|
Stanislav Ochotnicky |
395a42 |
This is a workaround for rhbz#968308 where a2x tries to write non-ASCII content
|
|
Stanislav Ochotnicky |
395a42 |
epub manifest. Since the write_file is mostly used to write xml content which
|
|
Stanislav Ochotnicky |
395a42 |
defaults to UTF-8 this seems fairly safe
|
|
Stanislav Ochotnicky |
395a42 |
---
|
|
Stanislav Ochotnicky |
395a42 |
a2x.py | 5 +++--
|
|
Stanislav Ochotnicky |
395a42 |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
Stanislav Ochotnicky |
395a42 |
|
|
Stanislav Ochotnicky |
395a42 |
diff --git a/a2x.py b/a2x.py
|
|
Stanislav Ochotnicky |
395a42 |
index 1b192a2..ad163e3 100755
|
|
Stanislav Ochotnicky |
395a42 |
--- a/a2x.py
|
|
Stanislav Ochotnicky |
395a42 |
+++ b/a2x.py
|
|
Stanislav Ochotnicky |
395a42 |
@@ -21,6 +21,7 @@ import urlparse
|
|
Stanislav Ochotnicky |
395a42 |
import zipfile
|
|
Stanislav Ochotnicky |
395a42 |
import xml.dom.minidom
|
|
Stanislav Ochotnicky |
395a42 |
import mimetypes
|
|
Stanislav Ochotnicky |
395a42 |
+import codecs
|
|
Stanislav Ochotnicky |
395a42 |
|
|
Stanislav Ochotnicky |
395a42 |
PROG = os.path.basename(os.path.splitext(__file__)[0])
|
|
Stanislav Ochotnicky |
395a42 |
VERSION = '8.6.8'
|
|
Stanislav Ochotnicky |
395a42 |
@@ -144,8 +145,8 @@ def find_executable(file_name):
|
|
Stanislav Ochotnicky |
395a42 |
result = _find_executable(file_name)
|
|
Stanislav Ochotnicky |
395a42 |
return result
|
|
Stanislav Ochotnicky |
395a42 |
|
|
Stanislav Ochotnicky |
395a42 |
-def write_file(filename, data, mode='w'):
|
|
Stanislav Ochotnicky |
395a42 |
- f = open(filename, mode)
|
|
Stanislav Ochotnicky |
395a42 |
+def write_file(filename, data, mode='w', encoding='utf-8'):
|
|
Stanislav Ochotnicky |
395a42 |
+ f = codecs.open(filename, mode, encoding)
|
|
Stanislav Ochotnicky |
395a42 |
try:
|
|
Stanislav Ochotnicky |
395a42 |
f.write(data)
|
|
Stanislav Ochotnicky |
395a42 |
finally:
|
|
Stanislav Ochotnicky |
395a42 |
--
|
|
Stanislav Ochotnicky |
395a42 |
1.8.4.2
|
|
Stanislav Ochotnicky |
395a42 |
|