tools v5.6.2

This commit is contained in:
Apprentice Alf
2013-02-07 10:28:25 +00:00
parent 490ee4e5d8
commit 748bd2d471
13 changed files with 65 additions and 67 deletions

View File

@@ -6,12 +6,15 @@ import locale
import codecs
# get sys.argv arguments and encode them into utf-8
def utf8_argv():
def unicode_argv():
if sys.platform.startswith('win'):
# Uses shell32.GetCommandLineArgvW to get sys.argv as a list of Unicode
# strings.
# Versions 2.x of Python don't support Unicode in sys.argv on
# Windows, with the underlying Windows API instead replacing multi-byte
# characters with '?'. So use shell32.GetCommandLineArgvW to get sys.argv
# as a list of Unicode strings and encode them as utf-8
# characters with '?'.
from ctypes import POINTER, byref, cdll, c_int, windll
from ctypes.wintypes import LPCWSTR, LPWSTR
@@ -30,23 +33,16 @@ def utf8_argv():
if argc.value > 0:
# Remove Python executable and commands if present
start = argc.value - len(sys.argv)
return [argv[i].encode('utf-8') for i in
return [argv[i] for i in
xrange(start, argc.value)]
# if we don't have any arguments at all, just pass back script name
# this should never happen
return None
return [u"DeDRM.py"]
else:
argv = []
argvencoding = sys.stdin.encoding
if argvencoding == None:
argvencoding = sys.getfilesystemencoding()
if argvencoding == None:
argvencoding = 'utf-8'
for arg in sys.argv:
if type(arg) == unicode:
argv.append(arg.encode('utf-8'))
else:
argv.append(arg.decode(argvencoding).encode('utf-8'))
return argv
argvencoding = "utf-8"
return [arg if (type(arg) == unicode) else unicode(arg,argvencoding) for arg in sys.argv]
def add_cp65001_codec():

View File

@@ -15,10 +15,10 @@ from __future__ import with_statement
# from <http://www.python.org/download/> and PyCrypto from
# <http://www.voidspace.org.uk/python/modules.shtml#pycrypto> (make sure to
# install the version for Python 2.6). Save this script file as
# ineptepub.pyw and double-click on it to run it.
# ineptpdf.pyw and double-click on it to run it.
#
# Mac OS X users: Save this script file as ineptepub.pyw. You can run this
# program from the command line (pythonw ineptepub.pyw) or by double-clicking
# Mac OS X users: Save this script file as ineptpdf.pyw. You can run this
# program from the command line (pythonw ineptpdf.pyw) or by double-clicking
# it when it has been associated with PythonLauncher.
# Revision history:
@@ -49,13 +49,14 @@ from __future__ import with_statement
# 7.10 - Various tweaks to fix minor problems.
# 7.11 - More tweaks to fix minor problems.
# 7.12 - Revised to allow use in calibre plugins to eliminate need for duplicate code
# 7.13 - Fixed erroneous mentions of ineptepub
"""
Decrypts Adobe ADEPT-encrypted PDF files.
"""
__license__ = 'GPL v3'
__version__ = "7.12"
__version__ = "7.13"
import sys
import os
@@ -115,7 +116,7 @@ def unicode_argv():
start = argc.value - len(sys.argv)
return [argv[i] for i in
xrange(start, argc.value)]
return [u"ineptepub.py"]
return [u"ineptpdf.py"]
else:
argvencoding = sys.stdin.encoding
if argvencoding == None: