From bc1f8dc1c72d3dd5a754cf378c25cf755fcc894c Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 15 Jan 2019 18:16:24 +0000 Subject: [PATCH] Modifications to work with MS Windows lxml only works with posix type paths so change path to this type to start with by the function posix_path(). also normpath removed in EpubWriter.py. This works with the test file but needs more comprehensive testing. Since Python works on windows with posix paths it might be possible to remove all os functions --- ebookmaker/EbookMaker.py | 6 +++++- ebookmaker/writers/EpubWriter.py | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ebookmaker/EbookMaker.py b/ebookmaker/EbookMaker.py index 65914d8..f7387b8 100644 --- a/ebookmaker/EbookMaker.py +++ b/ebookmaker/EbookMaker.py @@ -21,6 +21,7 @@ import logging import os.path import sys +import re import six from six.moves import cPickle @@ -410,6 +411,9 @@ def do_job (job): close_log (log_handler) log_handler = None +def posix_path(url): + url = re.sub('[A-Za-z]:', '', url) + return url.replace("\\", "/") def config (): """ Process config files and commandline params. """ @@ -433,7 +437,7 @@ def config (): ))) if '://' not in options.url: - options.url = os.path.abspath (options.url) + options.url = posix_path(os.path.abspath(options.url)) def main (): diff --git a/ebookmaker/writers/EpubWriter.py b/ebookmaker/writers/EpubWriter.py index 5ab14f1..a5615f3 100644 --- a/ebookmaker/writers/EpubWriter.py +++ b/ebookmaker/writers/EpubWriter.py @@ -1036,7 +1036,6 @@ def escape (matchobj): url = urllib.parse.unquote (url) url = re.sub ('^.*?://', '', url) - url = os.path.normpath (url) url = url.replace ('/', '@') url = re.sub ('[\\|/:?"*<>\u0000-\u001F]', escape, url)