/usr/share/pyshared/archmod/mod_chm.py is in archmage 1:0.2.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # -*- coding: utf-8 -*-
from mod_python import apache
from mimetypes import guess_type
from archmod.CHM import CHMFile
chmfile = None
chmname = None
def handler(req):
source = req.filename
pagename = req.path_info
global chmfile, chmname
if chmname != source:
chmfile = CHMFile(source)
chmname = source
if pagename:
try:
page = chmfile.get_entry(pagename)
except:
return apache.HTTP_NOT_FOUND
if pagename == '/':
mimetype = 'text/html'
else:
mimetype = guess_type(pagename)[0] or 'application/octet-stream'
req.content_type = mimetype
req.send_http_header()
req.write(page)
else:
mimetype = 'application/chm'
req.content_type = mimetype
req.send_http_header()
file = open(source, 'rb')
while 1:
tmp = file.read(4096)
if len(tmp) == 0:
break
req.write(tmp)
return apache.OK
|