From c56c1d6f4669ac05f329044041fbb424fdc6d927 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 22 Feb 2018 15:54:33 +0100 Subject: [PATCH] rclchm: very small change in support of py3, but there are lots of issue in python-chm itself --- src/filters/rclchm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/filters/rclchm b/src/filters/rclchm index 617f13f4..2e8fa600 100755 --- a/src/filters/rclchm +++ b/src/filters/rclchm @@ -13,8 +13,14 @@ import sys import os import re import posixpath -import urlparse -import urllib +PY3 = sys.version > '3' +if PY3: + from urllib.parse import unquote as urllib_unquote + from urllib.parse import urlparse as urlparse_urlparse +else: + from urlparse import urlparse as urlparse_urlparse + from urllib import unquote as urllib_unquote + import subprocess import rclconfig @@ -102,7 +108,7 @@ class ChmTopicsParser(HTMLParser): return # value may be url-encoded. Decode it. If there are no % in there, will # do nothing - value = urllib.unquote(value) + value = urllib_unquote(value) localpath = "" ll = value.split(":") @@ -149,7 +155,7 @@ class ChmWalker(HTMLParser): href = val path = "" - res = urlparse.urlparse(href) + res = urlparse_urlparse(href) if (not res.scheme or res.scheme.lower == "ms-its"): path = res.path lpath = path.split(':')