forked from expo/troggle
Convert codebase for python3 usage
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user