summaryrefslogtreecommitdiffstats
path: root/DeDRM_plugin/genbook.py
diff options
context:
space:
mode:
Diffstat (limited to 'DeDRM_plugin/genbook.py')
-rw-r--r--DeDRM_plugin/genbook.py24
1 files changed, 1 insertions, 23 deletions
diff --git a/DeDRM_plugin/genbook.py b/DeDRM_plugin/genbook.py
index 21186b8..b0624fd 100644
--- a/DeDRM_plugin/genbook.py
+++ b/DeDRM_plugin/genbook.py
@@ -4,29 +4,7 @@
# Python 3 for calibre 5.0
from __future__ import print_function
-# Wrap a stream so that output gets flushed immediately
-# and also make sure that any unicode strings get
-# encoded using "replace" before writing them.
-class SafeUnbuffered:
- def __init__(self, stream):
- self.stream = stream
- self.encoding = stream.encoding
- if self.encoding == None:
- self.encoding = "utf-8"
- def write(self, data):
- if isinstance(data,str) or isinstance(data,unicode):
- # str for Python3, unicode for Python2
- data = data.encode(self.encoding,"replace")
- try:
- buffer = getattr(self.stream, 'buffer', self.stream)
- # self.stream.buffer for Python3, self.stream for Python2
- buffer.write(data)
- buffer.flush()
- except:
- # We can do nothing if a write fails
- raise
- def __getattr__(self, attr):
- return getattr(self.stream, attr)
+from utilities import SafeUnbuffered
import sys
import csv