mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-23 23:54:44 +00:00
Python3: fix unicode in fileurl
This commit is contained in:
parent
5d26d2d93e
commit
b40f4722c7
1 changed files with 6 additions and 2 deletions
|
|
@ -34,6 +34,7 @@ try:
|
|||
except ImportError:
|
||||
# Python 3
|
||||
from urllib.request import urlopen
|
||||
from builtins import str as str_text
|
||||
from datetime import datetime
|
||||
|
||||
from . import urlbase, get_index_html
|
||||
|
|
@ -138,7 +139,10 @@ class FileUrl (urlbase.UrlBase):
|
|||
base_url = re.sub("^file://(/?)([a-zA-Z]):", r"file:///\2|", base_url)
|
||||
# transform file://path into file:///path
|
||||
base_url = re.sub("^file://([^/])", r"file:///\1", base_url)
|
||||
self.base_url = unicode(base_url)
|
||||
try:
|
||||
self.base_url = unicode(base_url)
|
||||
except NameError:
|
||||
self.base_url = base_url
|
||||
|
||||
def build_url (self):
|
||||
"""
|
||||
|
|
@ -214,7 +218,7 @@ class FileUrl (urlbase.UrlBase):
|
|||
with links to the files."""
|
||||
if self.is_directory():
|
||||
data = get_index_html(get_files(self.get_os_filename()))
|
||||
if isinstance(data, unicode):
|
||||
if isinstance(data, str_text):
|
||||
data = data.encode("iso8859-1", "ignore")
|
||||
else:
|
||||
data = super(FileUrl, self).read_content()
|
||||
|
|
|
|||
Loading…
Reference in a new issue