removing redundant functions

This commit is contained in:
Philip Sargent 2020-06-04 23:53:36 +01:00
parent 27816724f8
commit 681bfcb4c4
2 changed files with 28 additions and 30 deletions

View File

@ -10,30 +10,30 @@ import urllib.request, urllib.parse, urllib.error
# inlined use of fileabstraction into here # inlined use of fileabstraction into here
def fa_listdir(*path): # def fa_listdir(*path):
try: # try:
strippedpath = [p for p in path if p] # strippedpath = [p for p in path if p]
root = os.path.join(settings.FILES, *strippedpath ) # root = os.path.join(settings.FILES, *strippedpath )
l = "" # l = ""
#l = root + "\n" # #l = root + "\n"
isdir = os.path.isdir(root) #This seems to be required for os.path.isdir to work... # isdir = os.path.isdir(root) #This seems to be required for os.path.isdir to work...
#l += str(isdir) + "\n" # #l += str(isdir) + "\n"
for p in os.listdir(root): # for p in os.listdir(root):
if os.path.isdir(os.path.join(root, p)): # if os.path.isdir(os.path.join(root, p)):
l += p + "/\n" # l += p + "/\n"
elif os.path.isfile(os.path.join(root, p)): # elif os.path.isfile(os.path.join(root, p)):
l += p + "\n" # l += p + "\n"
#Ignore non-files and non-directories # #Ignore non-files and non-directories
return l # return l
except: # except:
if strippedpath: # if strippedpath:
c = reduce(urljoin, strippedpath) # c = reduce(urljoin, strippedpath)
else: # else:
c = "" # c = ""
c = c.replace("#", "%23") # c = c.replace("#", "%23")
print(("FILE: ", settings.FILES + "listdir/" + c)) # print(("FILE: ", settings.FILES + "listdir/" + c))
return urllib.request.urlopen(settings.FILES + "listdir/" + c).read() # return urllib.request.urlopen(settings.FILES + "listdir/" + c).read()
def fa_readFile(*path): def fa_readFile(*path):
try: try:
@ -52,11 +52,11 @@ def getMimeType(extension):
return "text/plain" return "text/plain"
def listdir(request, path): # def listdir(request, path):
#try: # #try:
return HttpResponse(fa_listdir(path), content_type="text/plain") # return HttpResponse(fa_listdir(path), content_type="text/plain")
#except: # #except:
# raise Http404 # # raise Http404
def upload(request, path): def upload(request, path):
pass pass

View File

@ -117,9 +117,7 @@ actualurlpatterns = patterns('',
url(r'^survexfile/(?P<survex_cave>.*)$', views_survex.survexcavesingle, name="survexcavessingle"), url(r'^survexfile/(?P<survex_cave>.*)$', views_survex.survexcavesingle, name="survexcavessingle"),
url(r'^survexfileraw/(?P<survex_file>.*?)\.svx$', views_survex.svxraw, name="svxraw"), url(r'^survexfileraw/(?P<survex_file>.*?)\.svx$', views_survex.svxraw, name="svxraw"),
(r'^survey_files/listdir/(?P<path>.*)$', view_surveys.listdir),
(r'^survey_files/download/(?P<path>.*)$', view_surveys.download), (r'^survey_files/download/(?P<path>.*)$', view_surveys.download),
#(r'^survey_files/upload/(?P<path>.*)$', view_surveys.upload),
#(r'^survey_scans/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.SURVEY_SCANS, 'show_indexes':True}), #(r'^survey_scans/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.SURVEY_SCANS, 'show_indexes':True}),
url(r'^survey_scans/$', view_surveys.surveyscansfolders, name="surveyscansfolders"), url(r'^survey_scans/$', view_surveys.surveyscansfolders, name="surveyscansfolders"),