2011-05-15 13:19:32 -04:00
|
|
|
# Bryan Schumaker (5 / 15 / 2011)
|
|
|
|
|
|
|
|
import root
|
2011-05-15 13:49:02 -04:00
|
|
|
import rpc
|
2011-05-15 13:19:32 -04:00
|
|
|
|
|
|
|
docs = {}
|
|
|
|
docs.update(root.docs)
|
2011-05-15 13:49:02 -04:00
|
|
|
docs.update(rpc.docs)
|
2011-05-15 13:19:32 -04:00
|
|
|
|
|
|
|
types = {
|
2011-05-15 13:49:02 -04:00
|
|
|
"html":"text/html",
|
2011-05-15 15:39:14 -04:00
|
|
|
"js":"text/javascript",
|
2011-12-22 14:16:33 -05:00
|
|
|
"png":"image/png",
|
2011-05-15 13:19:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
def lookup(file):
|
|
|
|
doc = docs
|
2011-05-15 15:39:14 -04:00
|
|
|
for i, cmp in enumerate(file):
|
2011-05-15 13:19:32 -04:00
|
|
|
doc = doc.get(cmp, None)
|
|
|
|
if doc == None:
|
|
|
|
break
|
2011-05-15 15:39:14 -04:00
|
|
|
elif len(doc) == 2:
|
|
|
|
break
|
|
|
|
return doc, i + 1
|
2011-05-15 13:19:32 -04:00
|
|
|
|
|
|
|
def has_file(file):
|
2011-05-15 15:39:14 -04:00
|
|
|
doc, index = lookup(file)
|
|
|
|
return doc != None
|
|
|
|
|
|
|
|
def file_type(file):
|
|
|
|
(func, type), index = lookup(file)
|
|
|
|
return type
|
2011-05-15 13:19:32 -04:00
|
|
|
|
2011-05-15 15:39:14 -04:00
|
|
|
def page_text(write, file):
|
|
|
|
(func, type), index = lookup(file)
|
|
|
|
if len(file) > index:
|
|
|
|
res = func(write, file[index:])
|
|
|
|
else:
|
|
|
|
res = func(write)
|