diff options
Diffstat (limited to 'DeDRM_plugin/ineptpdf.py')
-rwxr-xr-x | DeDRM_plugin/ineptpdf.py | 37 |
1 files changed, 2 insertions, 35 deletions
diff --git a/DeDRM_plugin/ineptpdf.py b/DeDRM_plugin/ineptpdf.py index 64e21f8..b34b38c 100755 --- a/DeDRM_plugin/ineptpdf.py +++ b/DeDRM_plugin/ineptpdf.py @@ -98,40 +98,7 @@ from utilities import SafeUnbuffered iswindows = sys.platform.startswith('win') isosx = sys.platform.startswith('darwin') -def unicode_argv(): - if iswindows: - # 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 '?'. - - - from ctypes import POINTER, byref, cdll, c_int, windll - from ctypes.wintypes import LPCWSTR, LPWSTR - - GetCommandLineW = cdll.kernel32.GetCommandLineW - GetCommandLineW.argtypes = [] - GetCommandLineW.restype = LPCWSTR - - CommandLineToArgvW = windll.shell32.CommandLineToArgvW - CommandLineToArgvW.argtypes = [LPCWSTR, POINTER(c_int)] - CommandLineToArgvW.restype = POINTER(LPWSTR) - - cmd = GetCommandLineW() - argc = c_int(0) - argv = CommandLineToArgvW(cmd, byref(argc)) - if argc.value > 0: - # Remove Python executable and commands if present - start = argc.value - len(sys.argv) - return [argv[i] for i in - range(start, argc.value)] - return ["ineptpdf.py"] - else: - argvencoding = sys.stdin.encoding or "utf-8" - return [arg if (isinstance(arg, str) or isinstance(arg,unicode)) else str(arg, argvencoding) for arg in sys.argv] - +from argv_utils import unicode_argv class ADEPTError(Exception): pass @@ -2305,7 +2272,7 @@ def getPDFencryptionType(inpath): def cli_main(): sys.stdout=SafeUnbuffered(sys.stdout) sys.stderr=SafeUnbuffered(sys.stderr) - argv=unicode_argv() + argv=unicode_argv("ineptpdf.py") progname = os.path.basename(argv[0]) if len(argv) != 4: print("usage: {0} <keyfile.der> <inbook.pdf> <outbook.pdf>".format(progname)) |