summaryrefslogtreecommitdiffstats
path: root/expo/fileAbstraction.py
diff options
context:
space:
mode:
authorsubstantialnoninfringinguser <substantialnoninfringinguser@gmail.com>2009-05-13 05:34:52 +0100
committersubstantialnoninfringinguser <substantialnoninfringinguser@gmail.com>2009-05-13 05:34:52 +0100
commitb66189bc9e506109766b7377a46b0321bcca71e5 (patch)
tree3b35a7e2e42af482ec6d07053d9abdc52f931372 /expo/fileAbstraction.py
parent832f1f53c6f3bd4e1323df728f8fe974df6f5dc4 (diff)
downloadtroggle-b66189bc9e506109766b7377a46b0321bcca71e5.tar.gz
troggle-b66189bc9e506109766b7377a46b0321bcca71e5.tar.bz2
troggle-b66189bc9e506109766b7377a46b0321bcca71e5.zip
[svn] Continued file abstracted work, to get survey files from either hard disk or the web.
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8173 by julian @ 1/18/2009 12:45 AM
Diffstat (limited to 'expo/fileAbstraction.py')
-rw-r--r--expo/fileAbstraction.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/expo/fileAbstraction.py b/expo/fileAbstraction.py
new file mode 100644
index 0000000..deb1a4a
--- /dev/null
+++ b/expo/fileAbstraction.py
@@ -0,0 +1,25 @@
+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))
+ return f.read() \ No newline at end of file