config_dir = ""
-# Wrap a stream so that output gets flushed immediately
-# and also make sure that any unicode strings get safely
-# 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
+
PLUGIN_NAME = __version.PLUGIN_NAME
PLUGIN_VERSION = __version.PLUGIN_VERSION
# For use with Topaz Scripts Version 2.6
# Python 3, September 2020
-# 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
#@@CALIBRE_COMPAT_CODE@@
-# 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
iswindows = sys.platform.startswith('win')
isosx = sys.platform.startswith('darwin')
# 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
except ImportError:
from Crypto.Cipher import AES
-# 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)
-
-try:
- from calibre.constants import iswindows, isosx
-except:
- iswindows = sys.platform.startswith('win')
- isosx = sys.platform.startswith('darwin')
+from utilities import SafeUnbuffered
def unicode_argv():
if iswindows:
import getopt
import re
-# 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
try:
- from calibre.constants import iswindows, isosx
+ from calibre.constants import iswindows
except:
iswindows = sys.platform.startswith('win')
- isosx = sys.platform.startswith('darwin')
def unicode_argv():
if iswindows:
return data[:-pad_len]
-# 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)
-
-try:
- from calibre.constants import iswindows, isosx
-except:
- iswindows = sys.platform.startswith('win')
- isosx = sys.platform.startswith('darwin')
+from utilities import SafeUnbuffered
def unicode_argv():
if iswindows:
return data[:-pad_len]
-# 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
iswindows = sys.platform.startswith('win')
isosx = sys.platform.startswith('darwin')
import androidkindlekey
import kfxdedrm
-# 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)
-
-iswindows = sys.platform.startswith('win')
-isosx = sys.platform.startswith('darwin')
+from utilities import SafeUnbuffered
def unicode_argv():
if iswindows:
# Routines common to Mac and PC
-# 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
try:
from calibre.constants import iswindows, isosx
import sys
import binascii
-# 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)
-
-iswindows = sys.platform.startswith('win')
-isosx = sys.platform.startswith('darwin')
+from utilities import SafeUnbuffered
def unicode_argv():
if iswindows:
except:
print("AlfCrypto not found. Using python PC1 implementation.")
-# 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
iswindows = sys.platform.startswith('win')
isosx = sys.platform.startswith('darwin')
from struct import unpack
from alfcrypto import Topaz_Cipher
+from utilities import SafeUnbuffered
-# 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)
-
-iswindows = sys.platform.startswith('win')
-isosx = sys.platform.startswith('darwin')
+from argv_utils import unicode_argv
def unicode_argv():
if iswindows:
except:
pass
return userkeys
+
+
+# Wrap a stream so that output gets flushed immediately
+# and also make sure that any unicode strings get safely
+# 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)
+
\ No newline at end of file