From 99ab1e22e9dfd8ca058cb2256ee01b6492659438 Mon Sep 17 00:00:00 2001 From: substantialnoninfringinguser Date: Wed, 13 May 2009 05:38:37 +0100 Subject: [svn] MOre work on abstracting the file locations on scanned survey notes Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8190 by julian @ 1/18/2009 9:04 PM --- expo/fileAbstraction.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'expo/fileAbstraction.py') diff --git a/expo/fileAbstraction.py b/expo/fileAbstraction.py index 4431480..299a488 100644 --- a/expo/fileAbstraction.py +++ b/expo/fileAbstraction.py @@ -25,9 +25,15 @@ def listdir(*path): c = reduce(urljoin, strippedpath) else: c = "" - print strippedpath, c - return urllib.urlopen(settings.FILES + "listdir/" + c) + c = c.replace("#", "%23") + print "FILE: ", settings.FILES + "listdir/" + c + return urllib.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] == "/"] +def filesAsList(*path): + return [d for d in listdir(*path).split("\n") if len(d) > 0 and d[-1] != "/"] def readFile(*path): try: -- cgit v1.2.3