mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-11-23 07:41:56 +00:00
[svn r8182] Changes to file abstraction, that seemed to make it work by magic
This commit is contained in:
parent
d03d7c2d1c
commit
ffe7d51c40
@ -1,25 +1,32 @@
|
|||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
import os
|
import os
|
||||||
|
import urllib
|
||||||
def urljoin(x, y): return x + "/" + y
|
|
||||||
|
def urljoin(x, y): return x + "/" + y
|
||||||
def listdir(*path):
|
|
||||||
try:
|
def listdir(*path):
|
||||||
l = ""
|
try:
|
||||||
root = os.path.join(settings.FILES, *path)
|
strippedpath = [p for p in path if p]
|
||||||
for p in os.listdir(root):
|
root = os.path.join(settings.FILES, *strippedpath )
|
||||||
if os.path.isdir(os.path.join(root, p)):
|
l = ""
|
||||||
l += p + "/\n"
|
#l = root + "\n"
|
||||||
elif os.path.isfile(os.path.join(root, p)):
|
#isdir = os.path.isdir(root)
|
||||||
l += p + "\n"
|
#l += str(isdir) + "\n"
|
||||||
#Ignore non-files and non-directories
|
for p in os.listdir(root):
|
||||||
return l
|
if os.path.isdir(os.path.join(root, p)):
|
||||||
except:
|
l += p + "/\n"
|
||||||
return urllib.urlopen(settings.FILES + "listdir/" + reduce(urljoin, path))
|
|
||||||
|
elif os.path.isfile(os.path.join(root, p)):
|
||||||
def readFile(*path):
|
l += p + "\n"
|
||||||
try:
|
#Ignore non-files and non-directories
|
||||||
f = open(os.path.join(settings.FILES, *path))
|
return l
|
||||||
except:
|
except:
|
||||||
f = urllib.urlopen(settings.FILES + "download/" + reduce(urljoin, path))
|
return urllib.urlopen(settings.FILES + "listdir/" + reduce(urljoin, strippedpath))
|
||||||
|
|
||||||
|
|
||||||
|
def readFile(*path):
|
||||||
|
try:
|
||||||
|
f = open(os.path.join(settings.FILES, *path))
|
||||||
|
except:
|
||||||
|
f = urllib.urlopen(settings.FILES + "download/" + reduce(urljoin, path))
|
||||||
return f.read()
|
return f.read()
|
Loading…
Reference in New Issue
Block a user