diff options
author | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-13 05:36:17 +0100 |
---|---|---|
committer | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-13 05:36:17 +0100 |
commit | 7f159a283a3eda32d45bc10bcf2d238950e8e1cf (patch) | |
tree | ee457f3956a496738807a7ca273362f76a75ff52 /expo/fileAbstraction.py | |
parent | f229ff35f909d7afea62ba2e1021a12cb0e16b22 (diff) | |
download | troggle-7f159a283a3eda32d45bc10bcf2d238950e8e1cf.tar.gz troggle-7f159a283a3eda32d45bc10bcf2d238950e8e1cf.tar.bz2 troggle-7f159a283a3eda32d45bc10bcf2d238950e8e1cf.zip |
[svn] Changes to file abstraction, that seemed to make it work by magic
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8182 by julian @ 1/18/2009 5:07 PM
Diffstat (limited to 'expo/fileAbstraction.py')
-rw-r--r-- | expo/fileAbstraction.py | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/expo/fileAbstraction.py b/expo/fileAbstraction.py index deb1a4a..a14eceb 100644 --- a/expo/fileAbstraction.py +++ b/expo/fileAbstraction.py @@ -1,25 +1,32 @@ -import troggle.settings as settings
-import os
-
-def urljoin(x, y): return x + "/" + y
-
-def listdir(*path):
- try:
- l = ""
- root = os.path.join(settings.FILES, *path)
- for p in os.listdir(root):
- if os.path.isdir(os.path.join(root, p)):
- l += p + "/\n"
- elif os.path.isfile(os.path.join(root, p)):
- l += p + "\n"
- #Ignore non-files and non-directories
- return l
- except:
- return urllib.urlopen(settings.FILES + "listdir/" + reduce(urljoin, path))
-
-def readFile(*path):
- try:
- f = open(os.path.join(settings.FILES, *path))
- except:
- f = urllib.urlopen(settings.FILES + "download/" + reduce(urljoin, path))
+import troggle.settings as settings +import os +import urllib + +def urljoin(x, y): return x + "/" + y + +def listdir(*path): + try: + strippedpath = [p for p in path if p] + root = os.path.join(settings.FILES, *strippedpath ) + l = "" + #l = root + "\n" + #isdir = os.path.isdir(root) + #l += str(isdir) + "\n" + for p in os.listdir(root): + if os.path.isdir(os.path.join(root, p)): + l += p + "/\n" + + elif os.path.isfile(os.path.join(root, p)): + l += p + "\n" + #Ignore non-files and non-directories + return l + except: + 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()
\ No newline at end of file |