Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Orange/data/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

from os import path, remove
from tempfile import NamedTemporaryFile
from urllib.parse import urlparse, urlsplit, urlunsplit, unquote as urlunquote
from urllib.parse import urlparse, urlsplit, urlunsplit, \
unquote as urlunquote, quote
from urllib.request import urlopen, Request
from pathlib import Path

Expand Down Expand Up @@ -405,6 +406,7 @@ def __init__(self, filename):
filename = filename.strip()
if not urlparse(filename).scheme:
filename = 'http://' + filename
filename = quote(filename, safe="/:")
super().__init__(filename)

@staticmethod
Expand Down
11 changes: 11 additions & 0 deletions Orange/tests/test_url_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,14 @@ def test_zipped(self):
"http://datasets.biolab.si/core/philadelphia-crime.csv.xz"
).read()
self.assertEqual(9666, len(data))

def test_special_characters(self):
# TO-DO - replace this file with a more appropriate one (e.g. .csv)
# and change the assertion accordingly
path = "http://file.biolab.si/text-semantics/data/elektrotehniski-" \
"vestnik-clanki/detektiranje-utrdb-v-šahu-.txt"
self.assertRaises(OSError, UrlReader(path).read)


if __name__ == "__main__":
unittest.main()