diff options
Diffstat (limited to 'core/fileAbstraction.py')
-rw-r--r-- | core/fileAbstraction.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/fileAbstraction.py b/core/fileAbstraction.py index 86191b7..0ebd6eb 100644 --- a/core/fileAbstraction.py +++ b/core/fileAbstraction.py @@ -1,6 +1,7 @@ import troggle.settings as settings import os -import urllib +import urllib.request, urllib.parse, urllib.error +from functools import reduce def urljoin(x, y): return x + "/" + y @@ -26,8 +27,8 @@ def listdir(*path): else: c = "" c = c.replace("#", "%23") - print("FILE: ", settings.FILES + "listdir/" + c) - return urllib.urlopen(settings.FILES + "listdir/" + c).read() + print(("FILE: ", settings.FILES + "listdir/" + c)) + return urllib.request.urlopen(settings.FILES + "listdir/" + c).read() def dirsAsList(*path): return [d for d in listdir(*path).split("\n") if len(d) > 0 and d[-1] == "/"] @@ -39,5 +40,5 @@ def readFile(*path): try: f = open(os.path.join(settings.FILES, *path)) except: - f = urllib.urlopen(settings.FILES + "download/" + reduce(urljoin, path)) + f = urllib.request.urlopen(settings.FILES + "download/" + reduce(urljoin, path)) return f.read()
\ No newline at end of file |