diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2020-06-04 23:38:57 +0100 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2020-06-04 23:38:57 +0100 |
commit | 27816724f81f1655bd605cdbd3161a19a0222dfe (patch) | |
tree | 80c2eaa64fff36989381c7792d3427689e83e4ef /core/fileAbstraction.py | |
parent | ac9ac5e397884770f801b787126b2b30ab9b5c93 (diff) | |
download | troggle-27816724f81f1655bd605cdbd3161a19a0222dfe.tar.gz troggle-27816724f81f1655bd605cdbd3161a19a0222dfe.tar.bz2 troggle-27816724f81f1655bd605cdbd3161a19a0222dfe.zip |
moved 2 funct, deletion of FileAbstraction pending
Diffstat (limited to 'core/fileAbstraction.py')
-rw-r--r-- | core/fileAbstraction.py | 51 |
1 files changed, 11 insertions, 40 deletions
diff --git a/core/fileAbstraction.py b/core/fileAbstraction.py index 0ebd6eb..0035bf8 100644 --- a/core/fileAbstraction.py +++ b/core/fileAbstraction.py @@ -1,44 +1,15 @@ -import troggle.settings as settings -import os -import urllib.request, urllib.parse, urllib.error -from functools import reduce +# import troggle.settings as settings +# import os +# import urllib.request, urllib.parse, urllib.error +# from functools import reduce -def urljoin(x, y): return x + "/" + y +# All unused, but kept pending deletion -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) #This seems to be required for os.path.isdir to work... - #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: - if strippedpath: - c = reduce(urljoin, strippedpath) - else: - c = "" - c = c.replace("#", "%23") - print(("FILE: ", settings.FILES + "listdir/" + c)) - return urllib.request.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 urljoin(x, y): return x + "/" + y -def filesAsList(*path): - return [d for d in listdir(*path).split("\n") if len(d) > 0 and d[-1] != "/"] +# 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: - f = open(os.path.join(settings.FILES, *path)) - except: - f = urllib.request.urlopen(settings.FILES + "download/" + reduce(urljoin, path)) - return f.read()
\ No newline at end of file |