Fix more Py2/Py3 stuff
This commit is contained in:
parent
10b6caf9f5
commit
ef67dbd204
|
@ -14,7 +14,8 @@ if "calibre" in sys.modules and sys.version_info[0] == 2:
|
||||||
if os.path.join(config_dir, "plugins", "DeDRM.zip") not in sys.path:
|
if os.path.join(config_dir, "plugins", "DeDRM.zip") not in sys.path:
|
||||||
sys.path.insert(0, os.path.join(config_dir, "plugins", "DeDRM.zip"))
|
sys.path.insert(0, os.path.join(config_dir, "plugins", "DeDRM.zip"))
|
||||||
|
|
||||||
# Explicitly set the package identifier so we are allowed to import stuff ...
|
if "calibre" in sys.modules:
|
||||||
__package__ = "calibre_plugins.dedrm"
|
# Explicitly set the package identifier so we are allowed to import stuff ...
|
||||||
|
__package__ = "calibre_plugins.dedrm"
|
||||||
|
|
||||||
#@@CALIBRE_COMPAT_CODE_END@@
|
#@@CALIBRE_COMPAT_CODE_END@@
|
||||||
|
|
|
@ -5,10 +5,21 @@
|
||||||
# (CLI interface without Calibre)
|
# (CLI interface without Calibre)
|
||||||
# Copyright © 2021 NoDRM
|
# Copyright © 2021 NoDRM
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
NOTE: This code is not functional (yet). I started working on it a while ago
|
||||||
|
to make a standalone version of the plugins that could work without Calibre,
|
||||||
|
too, but for now there's only a rough code structure and no working code yet.
|
||||||
|
|
||||||
|
Currently, to use these plugins, you will need to use Calibre. Hopwfully that'll
|
||||||
|
change in the future.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
# For revision history see __init__.py
|
# For revision history see CHANGELOG.md
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Run DeDRM plugin without Calibre.
|
Run DeDRM plugin without Calibre.
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
# For use with Topaz Scripts Version 2.6
|
# For use with Topaz Scripts Version 2.6
|
||||||
# Python 3, September 2020
|
# Python 3, September 2020
|
||||||
|
|
||||||
from utilities import SafeUnbuffered
|
|
||||||
|
#@@CALIBRE_COMPAT_CODE@@
|
||||||
|
|
||||||
|
from .utilities import SafeUnbuffered
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import csv
|
import csv
|
||||||
|
|
|
@ -49,6 +49,8 @@
|
||||||
|
|
||||||
__version__ = '2.0'
|
__version__ = '2.0'
|
||||||
|
|
||||||
|
#@@CALIBRE_COMPAT_CODE@@
|
||||||
|
|
||||||
import sys, struct, os, traceback
|
import sys, struct, os, traceback
|
||||||
import zlib
|
import zlib
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
# Python 3 for calibre 5.0
|
# Python 3 for calibre 5.0
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from utilities import SafeUnbuffered
|
#@@CALIBRE_COMPAT_CODE@@
|
||||||
|
|
||||||
|
from .utilities import SafeUnbuffered
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import csv
|
import csv
|
||||||
|
|
|
@ -45,6 +45,8 @@ import os
|
||||||
import hashlib
|
import hashlib
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
|
#@@CALIBRE_COMPAT_CODE@@
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from Cryptodome.Cipher import AES
|
from Cryptodome.Cipher import AES
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -27,6 +27,8 @@ import hashlib
|
||||||
import getopt
|
import getopt
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
#@@CALIBRE_COMPAT_CODE@@
|
||||||
|
|
||||||
from .utilities import SafeUnbuffered
|
from .utilities import SafeUnbuffered
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -70,6 +70,8 @@ def unpad(data, padding=16):
|
||||||
|
|
||||||
return data[:-pad_len]
|
return data[:-pad_len]
|
||||||
|
|
||||||
|
#@@CALIBRE_COMPAT_CODE@@
|
||||||
|
|
||||||
from .utilities import SafeUnbuffered
|
from .utilities import SafeUnbuffered
|
||||||
from .argv_utils import unicode_argv
|
from .argv_utils import unicode_argv
|
||||||
|
|
||||||
|
|
|
@ -92,13 +92,14 @@ def unpad(data, padding=16):
|
||||||
|
|
||||||
return data[:-pad_len]
|
return data[:-pad_len]
|
||||||
|
|
||||||
|
#@@CALIBRE_COMPAT_CODE@@
|
||||||
|
|
||||||
from .utilities import SafeUnbuffered
|
from .utilities import SafeUnbuffered
|
||||||
|
from .argv_utils import unicode_argv
|
||||||
|
|
||||||
iswindows = sys.platform.startswith('win')
|
iswindows = sys.platform.startswith('win')
|
||||||
isosx = sys.platform.startswith('darwin')
|
isosx = sys.platform.startswith('darwin')
|
||||||
|
|
||||||
from .argv_utils import unicode_argv
|
|
||||||
|
|
||||||
class ADEPTError(Exception):
|
class ADEPTError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -30,6 +30,9 @@ import struct
|
||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
#@@CALIBRE_COMPAT_CODE@@
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from Cryptodome.Cipher import AES
|
from Cryptodome.Cipher import AES
|
||||||
from Cryptodome.Util.py3compat import bchr
|
from Cryptodome.Util.py3compat import bchr
|
||||||
|
@ -57,7 +60,7 @@ except ImportError:
|
||||||
# Windows-friendly choice: pylzma wheels
|
# Windows-friendly choice: pylzma wheels
|
||||||
import pylzma as lzma
|
import pylzma as lzma
|
||||||
|
|
||||||
from kfxtables import *
|
from .kfxtables import *
|
||||||
|
|
||||||
TID_NULL = 0
|
TID_NULL = 0
|
||||||
TID_BOOLEAN = 1
|
TID_BOOLEAN = 1
|
||||||
|
|
|
@ -62,6 +62,8 @@ except NameError:
|
||||||
|
|
||||||
# Routines common to Mac and PC
|
# Routines common to Mac and PC
|
||||||
|
|
||||||
|
#@@CALIBRE_COMPAT_CODE@@
|
||||||
|
|
||||||
from .utilities import SafeUnbuffered
|
from .utilities import SafeUnbuffered
|
||||||
from .argv_utils import unicode_argv
|
from .argv_utils import unicode_argv
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,9 @@
|
||||||
import sys
|
import sys
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
from .utilities import SafeUnbuffered
|
#@@CALIBRE_COMPAT_CODE@@
|
||||||
|
|
||||||
|
from .utilities import SafeUnbuffered
|
||||||
from .argv_utils import unicode_argv
|
from .argv_utils import unicode_argv
|
||||||
|
|
||||||
letters = b'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789'
|
letters = b'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789'
|
||||||
|
|
Loading…
Reference in New Issue