/usr/lib/python2.6
NameSizeModeActions
bsddb/-0755rm
compiler/-0755rm
config/-0755rm
ctypes/-0755rm
curses/-0755rm
distutils/-0755rm
email/-0755rm
encodings/-0755rm
hotshot/-0755rm
idlelib/-0755rm
json/-0755rm
lib-dynload/-0755rm
lib2to3/-0755rm
logging/-0755rm
multiprocessing/-0755rm
plat-linux2/-0755rm
site-packages/-0755rm
sqlite3/-0755rm
test/-0755rm
wsgiref/-0755rm
xml/-0755rm
abc.py70340644editdlrm
abc.pyc60490644editdlrm
abc.pyo59910644editdlrm
aifc.py331880644editdlrm
aifc.pyc294240644editdlrm
aifc.pyo294240644editdlrm
anydbm.py26200644editdlrm
anydbm.pyc27690644editdlrm
anydbm.pyo27690644editdlrm
ast.py113470644editdlrm
ast.pyc127320644editdlrm
ast.pyo127320644editdlrm
asynchat.py114020644editdlrm
asynchat.pyc86770644editdlrm
asynchat.pyo86770644editdlrm
asyncore.py200610644editdlrm
asyncore.pyc183340644editdlrm
asyncore.pyo183340644editdlrm
atexit.py17050644editdlrm
atexit.pyc22030644editdlrm
atexit.pyo22030644editdlrm
audiodev.py75970644editdlrm
audiodev.pyc84830644editdlrm
audiodev.pyo84830644editdlrm
base64.py113350755editdlrm
base64.pyc109670644editdlrm
base64.pyo109670644editdlrm
BaseHTTPServer.py219740644editdlrm
BaseHTTPServer.pyc215350644editdlrm
BaseHTTPServer.pyo215350644editdlrm
Bastion.py57440644editdlrm
Bastion.pyc66370644editdlrm
Bastion.pyo66370644editdlrm
bdb.py205970644editdlrm
bdb.pyc184490644editdlrm
bdb.pyo184490644editdlrm
binhex.py148780644editdlrm
binhex.pyc157730644editdlrm
binhex.pyo157730644editdlrm
bisect.py26620644editdlrm
bisect.pyc31630644editdlrm
bisect.pyo31630644editdlrm
calendar.py231100644editdlrm
calendar.pyc280070644editdlrm
calendar.pyo280070644editdlrm
cgi.py344780755editdlrm
cgi.pyc326800644editdlrm
cgi.pyo326800644editdlrm
CGIHTTPServer.py127730644editdlrm
CGIHTTPServer.pyc107940644editdlrm
CGIHTTPServer.pyo107940644editdlrm
cgitb.py121550644editdlrm
cgitb.pyc124250644editdlrm
cgitb.pyo124250644editdlrm
chunk.py53720644editdlrm
chunk.pyc56230644editdlrm
chunk.pyo56230644editdlrm
cmd.py149620644editdlrm
cmd.pyc139140644editdlrm
cmd.pyo139140644editdlrm
code.py102170644editdlrm
code.pyc103950644editdlrm
code.pyo103950644editdlrm
codecs.py352660644editdlrm
codecs.pyc365330644editdlrm
codecs.pyo365330644editdlrm
codeop.py59990644editdlrm
codeop.pyc66160644editdlrm
codeop.pyo66160644editdlrm
collections.py137300644editdlrm
collections.pyc143920644editdlrm
collections.pyo143390644editdlrm
colorsys.py34590644editdlrm
colorsys.pyc40250644editdlrm
colorsys.pyo40250644editdlrm
commands.py25430644editdlrm
commands.pyc24770644editdlrm
commands.pyo24770644editdlrm
compileall.py52850644editdlrm
compileall.pyc49890644editdlrm
compileall.pyo49890644editdlrm
ConfigParser.py259890644editdlrm
ConfigParser.pyc237550644editdlrm
ConfigParser.pyo237550644editdlrm
contextlib.py41360644editdlrm
contextlib.pyc41270644editdlrm
contextlib.pyo41270644editdlrm
Cookie.py250540644editdlrm
Cookie.pyc220670644editdlrm
Cookie.pyo220670644editdlrm
cookielib.py647260644editdlrm
cookielib.pyc551760644editdlrm
cookielib.pyo549850644editdlrm
copy.py111770644editdlrm
copy.pyc116290644editdlrm
copy.pyo115330644editdlrm
copy_reg.py68000644editdlrm
copy_reg.pyc51560644editdlrm
copy_reg.pyo51100644editdlrm
cProfile.py63370755editdlrm
cProfile.pyc62110644editdlrm
cProfile.pyo62110644editdlrm
crypt.py22290644editdlrm
crypt.pyc30430644editdlrm
crypt.pyo30430644editdlrm
csv.py157300644editdlrm
csv.pyc131700644editdlrm
csv.pyo131700644editdlrm
dbhash.py5350644editdlrm
dbhash.pyc7560644editdlrm
dbhash.pyo7560644editdlrm
decimal.py1992730644editdlrm
decimal.pyc1551850644editdlrm
decimal.pyo1551190644editdlrm
difflib.py810800644editdlrm
difflib.pyc610930644editdlrm
difflib.pyo610390644editdlrm
dircache.py11260644editdlrm
dircache.pyc15760644editdlrm
dircache.pyo15760644editdlrm
dis.py64490644editdlrm
dis.pyc63500644editdlrm
dis.pyo63500644editdlrm
doctest.py1015160644editdlrm
doctest.pyc807820644editdlrm
doctest.pyo804940644editdlrm
DocXMLRPCServer.py105990644editdlrm
DocXMLRPCServer.pyc99210644editdlrm
DocXMLRPCServer.pyo98130644editdlrm
dumbdbm.py88200644editdlrm
dumbdbm.pyc65470644editdlrm
dumbdbm.pyo65470644editdlrm
dummy_thread.py44180644editdlrm
dummy_thread.pyc53830644editdlrm
dummy_thread.pyo53830644editdlrm
dummy_threading.py28040644editdlrm
dummy_threading.pyc12950644editdlrm
dummy_threading.pyo12950644editdlrm
filecmp.py94700644editdlrm
filecmp.pyc95920644editdlrm
filecmp.pyo95920644editdlrm
fileinput.py141430644editdlrm
fileinput.pyc148700644editdlrm
fileinput.pyo148700644editdlrm
fnmatch.py32390644editdlrm
fnmatch.pyc35670644editdlrm
fnmatch.pyo35670644editdlrm
formatter.py149110644editdlrm
formatter.pyc191490644editdlrm
formatter.pyo191490644editdlrm
fpformat.py46990644editdlrm
fpformat.pyc47190644editdlrm
fpformat.pyo47190644editdlrm
fractions.py200730644editdlrm
fractions.pyc180410644editdlrm
fractions.pyo180410644editdlrm
ftplib.py291970644editdlrm
ftplib.pyc283870644editdlrm
ftplib.pyo283870644editdlrm
functools.py21620644editdlrm
functools.pyc19210644editdlrm
functools.pyo19210644editdlrm
genericpath.py30200644editdlrm
genericpath.pyc32720644editdlrm
genericpath.pyo32720644editdlrm
getopt.py73280644editdlrm
getopt.pyc67100644editdlrm
getopt.pyo66630644editdlrm
getpass.py55340644editdlrm
getpass.pyc47400644editdlrm
getpass.pyo47400644editdlrm
gettext.py199680644editdlrm
gettext.pyc156740644editdlrm
gettext.pyo156740644editdlrm
glob.py22490644editdlrm
glob.pyc23950644editdlrm
glob.pyo23950644editdlrm
gzip.py167540644editdlrm
gzip.pyc143220644editdlrm
gzip.pyo143220644editdlrm
hashlib.py44270644editdlrm
hashlib.pyc39750644editdlrm
hashlib.pyo39750644editdlrm
heapq.py159950644editdlrm
heapq.pyc126680644editdlrm
heapq.pyo126680644editdlrm
hmac.py45310644editdlrm
hmac.pyc44890644editdlrm
hmac.pyo44890644editdlrm
htmlentitydefs.py180540644editdlrm
htmlentitydefs.pyc63690644editdlrm
htmlentitydefs.pyo63690644editdlrm
htmllib.py128690644editdlrm
htmllib.pyc202020644editdlrm
htmllib.pyo202020644editdlrm
HTMLParser.py135760644editdlrm
HTMLParser.pyc121980644editdlrm
HTMLParser.pyo118900644editdlrm
httplib.py487970644editdlrm
httplib.pyc375780644editdlrm
httplib.pyo373820644editdlrm
ihooks.py174520644editdlrm
ihooks.pyc206990644editdlrm
ihooks.pyo206200644editdlrm
imaplib.py477710644editdlrm
imaplib.pyc450270644editdlrm
imaplib.pyo422870644editdlrm
imghdr.py35440644editdlrm
imghdr.pyc48730644editdlrm
imghdr.pyo48730644editdlrm
imputil.py260090644editdlrm
imputil.pyc159590644editdlrm
imputil.pyo157870644editdlrm
inspect.py381890644editdlrm
inspect.pyc370330644editdlrm
inspect.pyo370330644editdlrm
io.py661650644editdlrm
io.pyc627120644editdlrm
io.pyo627120644editdlrm
keyword.py19970755editdlrm
keyword.pyc21130644editdlrm
keyword.pyo21130644editdlrm
linecache.py41280644editdlrm
linecache.pyc32560644editdlrm
linecache.pyo32560644editdlrm
locale.py826740644editdlrm
locale.pyc466200644editdlrm
locale.pyo466200644editdlrm
macpath.py62530644editdlrm
macpath.pyc76690644editdlrm
macpath.pyo76690644editdlrm
macurl2path.py32750644editdlrm
macurl2path.pyc28150644editdlrm
macurl2path.pyo28150644editdlrm
mailbox.py758240644editdlrm
mailbox.pyc756330644editdlrm
mailbox.pyo755840644editdlrm
mailcap.py84020644editdlrm
mailcap.pyc80510644editdlrm
mailcap.pyo80510644editdlrm
markupbase.py143500644editdlrm
markupbase.pyc94300644editdlrm
markupbase.pyo92360644editdlrm
md5.py4100644editdlrm
md5.pyc3760644editdlrm
md5.pyo3760644editdlrm
mhlib.py334340644editdlrm
mhlib.pyc339810644editdlrm
mhlib.pyo339810644editdlrm
mimetools.py71680644editdlrm
mimetools.pyc82800644editdlrm
mimetools.pyo82800644editdlrm
mimetypes.py188220644editdlrm
mimetypes.pyc168380644editdlrm
mimetypes.pyo168380644editdlrm
MimeWriter.py64820644editdlrm
MimeWriter.pyc73650644editdlrm
MimeWriter.pyo73650644editdlrm
mimify.py150240755editdlrm
mimify.pyc121890644editdlrm
mimify.pyo121890644editdlrm
modulefinder.py242830644editdlrm
modulefinder.pyc189390644editdlrm
modulefinder.pyo188510644editdlrm
multifile.py48200644editdlrm
multifile.pyc54490644editdlrm
multifile.pyo54050644editdlrm
mutex.py18660644editdlrm
mutex.pyc25120644editdlrm
mutex.pyo25120644editdlrm
netrc.py41110644editdlrm
netrc.pyc35860644editdlrm
netrc.pyo35860644editdlrm
new.py7060644editdlrm
new.pyc9080644editdlrm
new.pyo9080644editdlrm
nntplib.py214700644editdlrm
nntplib.pyc210910644editdlrm
nntplib.pyo210910644editdlrm
ntpath.py177520644editdlrm
ntpath.pyc115820644editdlrm
ntpath.pyo115350644editdlrm
nturl2path.py22390644editdlrm
nturl2path.pyc17710644editdlrm
nturl2path.pyo17710644editdlrm
numbers.py102710644editdlrm
numbers.pyc138400644editdlrm
numbers.pyo138400644editdlrm
opcode.py52480644editdlrm
opcode.pyc59070644editdlrm
opcode.pyo59070644editdlrm
optparse.py608490644editdlrm
optparse.pyc539590644editdlrm
optparse.pyo538770644editdlrm
ordereddict.py360644editdlrm
ordereddict.pyc1830644editdlrm
ordereddict.pyo1830644editdlrm
os.py258020644editdlrm
os.pyc257020644editdlrm
os.pyo257020644editdlrm
os2emxpath.py46030644editdlrm
os2emxpath.pyc45180644editdlrm
os2emxpath.pyo45180644editdlrm
pdb.doc78990644editdlrm
pdb.py453330755editdlrm
pdb.pyc435850644editdlrm
pdb.pyo435850644editdlrm
pickle.py448110644editdlrm
pickle.pyc384370644editdlrm
pickle.pyo382320644editdlrm
pickletools.py743480644editdlrm
pickletools.pyc570790644editdlrm
pickletools.pyo561820644editdlrm
pipes.py96470644editdlrm
pipes.pyc94280644editdlrm
pipes.pyo94280644editdlrm
pkgutil.py200010644editdlrm
pkgutil.pyc189540644editdlrm
pkgutil.pyo189540644editdlrm
platform.py526300755editdlrm
platform.pyc386990644editdlrm
platform.pyo386990644editdlrm
plistlib.py158060644editdlrm
plistlib.pyc199260644editdlrm
plistlib.pyo198360644editdlrm
popen2.py84160644editdlrm
popen2.pyc90320644editdlrm
popen2.pyo89880644editdlrm
poplib.py128250644editdlrm
poplib.pyc133520644editdlrm
poplib.pyo133520644editdlrm
posixfile.py80030644editdlrm
posixfile.pyc77000644editdlrm
posixfile.pyo77000644editdlrm
posixpath.py131190644editdlrm
posixpath.pyc111420644editdlrm
posixpath.pyo111420644editdlrm
pprint.py119320644editdlrm
pprint.pyc103560644editdlrm
pprint.pyo101810644editdlrm
profile.py235100755editdlrm
profile.pyc166000644editdlrm
profile.pyo163550644editdlrm
pstats.py273100644editdlrm
pstats.pyc252120644editdlrm
pstats.pyo252120644editdlrm
pty.py48690644editdlrm
pty.pyc48990644editdlrm
pty.pyo48990644editdlrm
pyclbr.py132820644editdlrm
pyclbr.pyc97060644editdlrm
pyclbr.pyo97060644editdlrm
pydoc.py924320755editdlrm
pydoc.pyc906620644editdlrm
pydoc.pyo905940644editdlrm
pydoc_topics.py4231260644editdlrm
pydoc_topics.pyc4075860644editdlrm
pydoc_topics.pyo4075860644editdlrm
py_compile.py56330644editdlrm
py_compile.pyc65360644editdlrm
py_compile.pyo65360644editdlrm
Queue.py85740644editdlrm
Queue.pyc93910644editdlrm
Queue.pyo93910644editdlrm
quopri.py69720755editdlrm
quopri.pyc66660644editdlrm
quopri.pyo66660644editdlrm
random.py319660644editdlrm
random.pyc250240644editdlrm
random.pyo250240644editdlrm
re.py129660644editdlrm
re.pyc131220644editdlrm
re.pyo131220644editdlrm
repr.py42960644editdlrm
repr.pyc54000644editdlrm
repr.pyo54000644editdlrm
rexec.py201520644editdlrm
rexec.pyc241020644editdlrm
rexec.pyo241020644editdlrm
rfc822.py332950644editdlrm
rfc822.pyc319900644editdlrm
rfc822.pyo319900644editdlrm
rlcompleter.py58660644editdlrm
rlcompleter.pyc60570644editdlrm
rlcompleter.pyo60570644editdlrm
robotparser.py70140644editdlrm
robotparser.pyc78040644editdlrm
robotparser.pyo78040644editdlrm
runpy.py54130644editdlrm
runpy.pyc39650644editdlrm
runpy.pyo39650644editdlrm
sched.py50910644editdlrm
sched.pyc49870644editdlrm
sched.pyo49870644editdlrm
sets.py190500644editdlrm
sets.pyc168850644editdlrm
sets.pyo168850644editdlrm
sgmllib.py178840644editdlrm
sgmllib.pyc155040644editdlrm
sgmllib.pyo155040644editdlrm
sha.py4450644editdlrm
sha.pyc4190644editdlrm
sha.pyo4190644editdlrm
shelve.py80780644editdlrm
shelve.pyc102420644editdlrm
shelve.pyo102420644editdlrm
shlex.py111370644editdlrm
shlex.pyc76840644editdlrm
shlex.pyo76840644editdlrm
shutil.py86320644editdlrm
shutil.pyc95190644editdlrm
shutil.pyo95190644editdlrm
SimpleHTTPServer.py74220644editdlrm
SimpleHTTPServer.pyc77440644editdlrm
SimpleHTTPServer.pyo77440644editdlrm
SimpleXMLRPCServer.py219920644editdlrm
SimpleXMLRPCServer.pyc195750644editdlrm
SimpleXMLRPCServer.pyo195750644editdlrm
site.py189270644editdlrm
site.pyc186630644editdlrm
site.pyo186630644editdlrm
smtpd.py189200755editdlrm
smtpd.pyc161260644editdlrm
smtpd.pyo161260644editdlrm
smtplib.py309240755editdlrm
smtplib.pyc296290644editdlrm
smtplib.pyo296290644editdlrm
sndhdr.py59730644editdlrm
sndhdr.pyc73860644editdlrm
sndhdr.pyo73860644editdlrm
socket.py201490644editdlrm
socket.pyc160670644editdlrm
socket.pyo159820644editdlrm
SocketServer.py223260644editdlrm
SocketServer.pyc230350644editdlrm
SocketServer.pyo230350644editdlrm
sre.py3840644editdlrm
sre.pyc5170644editdlrm
sre.pyo5170644editdlrm
sre_compile.py165070644editdlrm
sre_compile.pyc114550644editdlrm
sre_compile.pyo113420644editdlrm
sre_constants.py71370644editdlrm
sre_constants.pyc60830644editdlrm
sre_constants.pyo60830644editdlrm
sre_parse.py268780644editdlrm
sre_parse.pyc196220644editdlrm
sre_parse.pyo196220644editdlrm
ssl.py166770644editdlrm
ssl.pyc142180644editdlrm
ssl.pyo142180644editdlrm
stat.py17180644editdlrm
stat.pyc26830644editdlrm
stat.pyo26830644editdlrm
statvfs.py8980644editdlrm
statvfs.pyc6180644editdlrm
statvfs.pyo6180644editdlrm
string.py207450644editdlrm
string.pyc199640644editdlrm
string.pyo199640644editdlrm
StringIO.py106210644editdlrm
StringIO.pyc114940644editdlrm
StringIO.pyo114940644editdlrm
stringold.py124490644editdlrm
stringold.pyc125390644editdlrm
stringold.pyo125390644editdlrm
stringprep.py135220644editdlrm
stringprep.pyc144860644editdlrm
stringprep.pyo144120644editdlrm
struct.py820644editdlrm
struct.pyc2370644editdlrm
struct.pyo2370644editdlrm
subprocess.py579450644editdlrm
subprocess.pyc409750644editdlrm
subprocess.pyo409180644editdlrm
sunau.py165370644editdlrm
sunau.pyc179760644editdlrm
sunau.pyo179760644editdlrm
sunaudio.py13990644editdlrm
sunaudio.pyc19870644editdlrm
sunaudio.pyo19870644editdlrm
symbol.py20500755editdlrm
symbol.pyc30210644editdlrm
symbol.pyo30210644editdlrm
symtable.py79110644editdlrm
symtable.pyc125030644editdlrm
symtable.pyo123730644editdlrm
tabnanny.py113390755editdlrm
tabnanny.pyc82930644editdlrm
tabnanny.pyo82930644editdlrm
tarfile.py877860644editdlrm
tarfile.pyc735960644editdlrm
tarfile.pyo735960644editdlrm
telnetlib.py218080644editdlrm
telnetlib.pyc198550644editdlrm
telnetlib.pyo198550644editdlrm
tempfile.py177740644editdlrm
tempfile.pyc194630644editdlrm
tempfile.pyo194630644editdlrm
textwrap.py168890644editdlrm
textwrap.pyc117660644editdlrm
textwrap.pyo116740644editdlrm
this.py10020644editdlrm
this.pyc12390644editdlrm
this.pyo12390644editdlrm
threading.py318080644editdlrm
threading.pyc279560644editdlrm
threading.pyo258840644editdlrm
timeit.py120030644editdlrm
timeit.pyc118010644editdlrm
timeit.pyo118010644editdlrm
toaiff.py31420644editdlrm
toaiff.pyc31260644editdlrm
toaiff.pyo31260644editdlrm
token.py29470755editdlrm
token.pyc38300644editdlrm
token.pyo38300644editdlrm
tokenize.py163260644editdlrm
tokenize.pyc139860644editdlrm
tokenize.pyo138930644editdlrm
trace.py303250644editdlrm
trace.pyc229890644editdlrm
trace.pyo229270644editdlrm
traceback.py112110644editdlrm
traceback.pyc116370644editdlrm
traceback.pyo116370644editdlrm
tty.py8790644editdlrm
tty.pyc13110644editdlrm
tty.pyo13110644editdlrm
types.py23230644editdlrm
types.pyc26080644editdlrm
types.pyo26080644editdlrm
unittest.py311570644editdlrm
unittest.pyc346560644editdlrm
unittest.pyo346560644editdlrm
urllib.py590220644editdlrm
urllib.pyc511420644editdlrm
urllib.pyo510480644editdlrm
urllib2.py508660644editdlrm
urllib2.pyc455690644editdlrm
urllib2.pyo454750644editdlrm
urlparse.py156180644editdlrm
urlparse.pyc147270644editdlrm
urlparse.pyo147270644editdlrm
user.py16270644editdlrm
user.pyc17340644editdlrm
user.pyo17340644editdlrm
UserDict.py57780644editdlrm
UserDict.pyc88020644editdlrm
UserDict.pyo88020644editdlrm
UserList.py36440644editdlrm
UserList.pyc65350644editdlrm
UserList.pyo65350644editdlrm
UserString.py96910755editdlrm
UserString.pyc147860644editdlrm
UserString.pyo147860644editdlrm
uu.py59420755editdlrm
uu.pyc42270644editdlrm
uu.pyo42270644editdlrm
uuid.py209440644editdlrm
uuid.pyc212050644editdlrm
uuid.pyo212050644editdlrm
warnings.py141720644editdlrm
warnings.pyc129960644editdlrm
warnings.pyo121590644editdlrm
wave.py179520644editdlrm
wave.pyc193360644editdlrm
wave.pyo193360644editdlrm
weakref.py100870644editdlrm
weakref.pyc132770644editdlrm
weakref.pyo132770644editdlrm
webbrowser.py210730644editdlrm
webbrowser.pyc186690644editdlrm
webbrowser.pyo186220644editdlrm
whichdb.py33530644editdlrm
whichdb.pyc22430644editdlrm
whichdb.pyo22430644editdlrm
xdrlib.py55130644editdlrm
xdrlib.pyc90790644editdlrm
xdrlib.pyo90790644editdlrm
xmllib.py348650644editdlrm
xmllib.pyc271660644editdlrm
xmllib.pyo271660644editdlrm
xmlrpclib.py477750644editdlrm
xmlrpclib.pyc412300644editdlrm
xmlrpclib.pyo410470644editdlrm
zipfile.py530920644editdlrm
zipfile.pyc375470644editdlrm
zipfile.pyo375470644editdlrm
_abcoll.py142420644editdlrm
_abcoll.pyc213950644editdlrm
_abcoll.pyo213950644editdlrm
_LWPCookieJar.py65530644editdlrm
_LWPCookieJar.pyc55890644editdlrm
_LWPCookieJar.pyo55890644editdlrm
_MozillaCookieJar.py58090644editdlrm
_MozillaCookieJar.pyc45090644editdlrm
_MozillaCookieJar.pyo44680644editdlrm
_strptime.py197540644editdlrm
_strptime.pyc149260644editdlrm
_strptime.pyo149260644editdlrm
_threading_local.py71140644editdlrm
_threading_local.pyc63670644editdlrm
_threading_local.pyo63670644editdlrm
__future__.py43800644editdlrm
__future__.pyc42210644editdlrm
__future__.pyo42210644editdlrm
__phello__.foo.py640644editdlrm
__phello__.foo.pyc1230644editdlrm
__phello__.foo.pyo1230644editdlrm
Edit: /usr/lib/python2.6/cgi.py (34478B)
#! /usr/bin/env python2.6 # NOTE: the above "/usr/local/bin/python" is NOT a mistake. It is # intentionally NOT "/usr/bin/env python". On many systems # (e.g. Solaris), /usr/local/bin is not in $PATH as passed to CGI # scripts, and /usr/local/bin is the default directory where Python is # installed, so /usr/bin/env would be unable to find python. Granted, # binary installations by Linux vendors often install Python in # /usr/bin. So let those vendors patch cgi.py to match their choice # of installation. """Support module for CGI (Common Gateway Interface) scripts. This module defines a number of utilities for use by CGI scripts written in Python. """ # XXX Perhaps there should be a slimmed version that doesn't contain # all those backwards compatible and debugging classes and functions? # History # ------- # # Michael McLay started this module. Steve Majewski changed the # interface to SvFormContentDict and FormContentDict. The multipart # parsing was inspired by code submitted by Andreas Paepcke. Guido van # Rossum rewrote, reformatted and documented the module and is currently # responsible for its maintenance. # __version__ = "2.6" # Imports # ======= from operator import attrgetter import sys import os import urllib import UserDict import urlparse from warnings import filterwarnings, catch_warnings, warn with catch_warnings(): if sys.py3kwarning: filterwarnings("ignore", ".*mimetools has been removed", DeprecationWarning) import mimetools if sys.py3kwarning: filterwarnings("ignore", ".*rfc822 has been removed", DeprecationWarning) import rfc822 try: from cStringIO import StringIO except ImportError: from StringIO import StringIO __all__ = ["MiniFieldStorage", "FieldStorage", "FormContentDict", "SvFormContentDict", "InterpFormContentDict", "FormContent", "parse", "parse_qs", "parse_qsl", "parse_multipart", "parse_header", "print_exception", "print_environ", "print_form", "print_directory", "print_arguments", "print_environ_usage", "escape"] # Logging support # =============== logfile = "" # Filename to log to, if not empty logfp = None # File object to log to, if not None def initlog(*allargs): """Write a log message, if there is a log file. Even though this function is called initlog(), you should always use log(); log is a variable that is set either to initlog (initially), to dolog (once the log file has been opened), or to nolog (when logging is disabled). The first argument is a format string; the remaining arguments (if any) are arguments to the % operator, so e.g. log("%s: %s", "a", "b") will write "a: b" to the log file, followed by a newline. If the global logfp is not None, it should be a file object to which log data is written. If the global logfp is None, the global logfile may be a string giving a filename to open, in append mode. This file should be world writable!!! If the file can't be opened, logging is silently disabled (since there is no safe place where we could send an error message). """ global logfp, log if logfile and not logfp: try: logfp = open(logfile, "a") except IOError: pass if not logfp: log = nolog else: log = dolog log(*allargs) def dolog(fmt, *args): """Write a log message to the log file. See initlog() for docs.""" logfp.write(fmt%args + "\n") def nolog(*allargs): """Dummy function, assigned to log when logging is disabled.""" pass log = initlog # The current logging function # Parsing functions # ================= # Maximum input we will accept when REQUEST_METHOD is POST # 0 ==> unlimited input maxlen = 0 def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0): """Parse a query in the environment or from a file (default stdin) Arguments, all optional: fp : file pointer; default: sys.stdin environ : environment dictionary; default: os.environ keep_blank_values: flag indicating whether blank values in URL encoded forms should be treated as blank strings. A true value indicates that blanks should be retained as blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. strict_parsing: flag indicating what to do with parsing errors. If false (the default), errors are silently ignored. If true, errors raise a ValueError exception. """ if fp is None: fp = sys.stdin if not 'REQUEST_METHOD' in environ: environ['REQUEST_METHOD'] = 'GET' # For testing stand-alone if environ['REQUEST_METHOD'] == 'POST': ctype, pdict = parse_header(environ['CONTENT_TYPE']) if ctype == 'multipart/form-data': return parse_multipart(fp, pdict) elif ctype == 'application/x-www-form-urlencoded': clength = int(environ['CONTENT_LENGTH']) if maxlen and clength > maxlen: raise ValueError, 'Maximum content length exceeded' qs = fp.read(clength) else: qs = '' # Unknown content-type if 'QUERY_STRING' in environ: if qs: qs = qs + '&' qs = qs + environ['QUERY_STRING'] elif sys.argv[1:]: if qs: qs = qs + '&' qs = qs + sys.argv[1] environ['QUERY_STRING'] = qs # XXX Shouldn't, really elif 'QUERY_STRING' in environ: qs = environ['QUERY_STRING'] else: if sys.argv[1:]: qs = sys.argv[1] else: qs = "" environ['QUERY_STRING'] = qs # XXX Shouldn't, really return urlparse.parse_qs(qs, keep_blank_values, strict_parsing) # parse query string function called from urlparse, # this is done in order to maintain backward compatiblity. def parse_qs(qs, keep_blank_values=0, strict_parsing=0): """Parse a query given as a string argument.""" warn("cgi.parse_qs is deprecated, use urlparse.parse_qs \ instead", PendingDeprecationWarning, 2) return urlparse.parse_qs(qs, keep_blank_values, strict_parsing) def parse_qsl(qs, keep_blank_values=0, strict_parsing=0): """Parse a query given as a string argument.""" warn("cgi.parse_qsl is deprecated, use urlparse.parse_qsl instead", PendingDeprecationWarning, 2) return urlparse.parse_qsl(qs, keep_blank_values, strict_parsing) def parse_multipart(fp, pdict): """Parse multipart input. Arguments: fp : input file pdict: dictionary containing other parameters of content-type header Returns a dictionary just like parse_qs(): keys are the field names, each value is a list of values for that field. This is easy to use but not much good if you are expecting megabytes to be uploaded -- in that case, use the FieldStorage class instead which is much more flexible. Note that content-type is the raw, unparsed contents of the content-type header. XXX This does not parse nested multipart parts -- use FieldStorage for that. XXX This should really be subsumed by FieldStorage altogether -- no point in having two implementations of the same parsing algorithm. Also, FieldStorage protects itself better against certain DoS attacks by limiting the size of the data read in one chunk. The API here does not support that kind of protection. This also affects parse() since it can call parse_multipart(). """ boundary = "" if 'boundary' in pdict: boundary = pdict['boundary'] if not valid_boundary(boundary): raise ValueError, ('Invalid boundary in multipart form: %r' % (boundary,)) nextpart = "--" + boundary lastpart = "--" + boundary + "--" partdict = {} terminator = "" while terminator != lastpart: bytes = -1 data = None if terminator: # At start of next part. Read headers first. headers = mimetools.Message(fp) clength = headers.getheader('content-length') if clength: try: bytes = int(clength) except ValueError: pass if bytes > 0: if maxlen and bytes > maxlen: raise ValueError, 'Maximum content length exceeded' data = fp.read(bytes) else: data = "" # Read lines until end of part. lines = [] while 1: line = fp.readline() if not line: terminator = lastpart # End outer loop break if line[:2] == "--": terminator = line.strip() if terminator in (nextpart, lastpart): break lines.append(line) # Done with part. if data is None: continue if bytes < 0: if lines: # Strip final line terminator line = lines[-1] if line[-2:] == "\r\n": line = line[:-2] elif line[-1:] == "\n": line = line[:-1] lines[-1] = line data = "".join(lines) line = headers['content-disposition'] if not line: continue key, params = parse_header(line) if key != 'form-data': continue if 'name' in params: name = params['name'] else: continue if name in partdict: partdict[name].append(data) else: partdict[name] = [data] return partdict def _parseparam(s): while s[:1] == ';': s = s[1:] end = s.find(';') while end > 0 and s.count('"', 0, end) % 2: end = s.find(';', end + 1) if end < 0: end = len(s) f = s[:end] yield f.strip() s = s[end:] def parse_header(line): """Parse a Content-type like header. Return the main content-type and a dictionary of options. """ parts = _parseparam(';' + line) key = parts.next() pdict = {} for p in parts: i = p.find('=') if i >= 0: name = p[:i].strip().lower() value = p[i+1:].strip() if len(value) >= 2 and value[0] == value[-1] == '"': value = value[1:-1] value = value.replace('\\\\', '\\').replace('\\"', '"') pdict[name] = value return key, pdict # Classes for field storage # ========================= class MiniFieldStorage: """Like FieldStorage, for use when no file uploads are possible.""" # Dummy attributes filename = None list = None type = None file = None type_options = {} disposition = None disposition_options = {} headers = {} def __init__(self, name, value): """Constructor from field name and value.""" self.name = name self.value = value # self.file = StringIO(value) def __repr__(self): """Return printable representation.""" return "MiniFieldStorage(%r, %r)" % (self.name, self.value) class FieldStorage: """Store a sequence of fields, reading multipart/form-data. This class provides naming, typing, files stored on disk, and more. At the top level, it is accessible like a dictionary, whose keys are the field names. (Note: None can occur as a field name.) The items are either a Python list (if there's multiple values) or another FieldStorage or MiniFieldStorage object. If it's a single object, it has the following attributes: name: the field name, if specified; otherwise None filename: the filename, if specified; otherwise None; this is the client side filename, *not* the file name on which it is stored (that's a temporary file you don't deal with) value: the value as a *string*; for file uploads, this transparently reads the file every time you request the value file: the file(-like) object from which you can read the data; None if the data is stored a simple string type: the content-type, or None if not specified type_options: dictionary of options specified on the content-type line disposition: content-disposition, or None if not specified disposition_options: dictionary of corresponding options headers: a dictionary(-like) object (sometimes rfc822.Message or a subclass thereof) containing *all* headers The class is subclassable, mostly for the purpose of overriding the make_file() method, which is called internally to come up with a file open for reading and writing. This makes it possible to override the default choice of storing all files in a temporary directory and unlinking them as soon as they have been opened. """ def __init__(self, fp=None, headers=None, outerboundary="", environ=os.environ, keep_blank_values=0, strict_parsing=0): """Constructor. Read multipart/* until last part. Arguments, all optional: fp : file pointer; default: sys.stdin (not used when the request method is GET) headers : header dictionary-like object; default: taken from environ as per CGI spec outerboundary : terminating multipart boundary (for internal use only) environ : environment dictionary; default: os.environ keep_blank_values: flag indicating whether blank values in URL encoded forms should be treated as blank strings. A true value indicates that blanks should be retained as blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. strict_parsing: flag indicating what to do with parsing errors. If false (the default), errors are silently ignored. If true, errors raise a ValueError exception. """ method = 'GET' self.keep_blank_values = keep_blank_values self.strict_parsing = strict_parsing if 'REQUEST_METHOD' in environ: method = environ['REQUEST_METHOD'].upper() self.qs_on_post = None if method == 'GET' or method == 'HEAD': if 'QUERY_STRING' in environ: qs = environ['QUERY_STRING'] elif sys.argv[1:]: qs = sys.argv[1] else: qs = "" fp = StringIO(qs) if headers is None: headers = {'content-type': "application/x-www-form-urlencoded"} if headers is None: headers = {} if method == 'POST': # Set default content-type for POST to what's traditional headers['content-type'] = "application/x-www-form-urlencoded" if 'CONTENT_TYPE' in environ: headers['content-type'] = environ['CONTENT_TYPE'] if 'QUERY_STRING' in environ: self.qs_on_post = environ['QUERY_STRING'] if 'CONTENT_LENGTH' in environ: headers['content-length'] = environ['CONTENT_LENGTH'] self.fp = fp or sys.stdin self.headers = headers self.outerboundary = outerboundary # Process content-disposition header cdisp, pdict = "", {} if 'content-disposition' in self.headers: cdisp, pdict = parse_header(self.headers['content-disposition']) self.disposition = cdisp self.disposition_options = pdict self.name = None if 'name' in pdict: self.name = pdict['name'] self.filename = None if 'filename' in pdict: self.filename = pdict['filename'] # Process content-type header # # Honor any existing content-type header. But if there is no # content-type header, use some sensible defaults. Assume # outerboundary is "" at the outer level, but something non-false # inside a multi-part. The default for an inner part is text/plain, # but for an outer part it should be urlencoded. This should catch # bogus clients which erroneously forget to include a content-type # header. # # See below for what we do if there does exist a content-type header, # but it happens to be something we don't understand. if 'content-type' in self.headers: ctype, pdict = parse_header(self.headers['content-type']) elif self.outerboundary or method != 'POST': ctype, pdict = "text/plain", {} else: ctype, pdict = 'application/x-www-form-urlencoded', {} self.type = ctype self.type_options = pdict self.innerboundary = "" if 'boundary' in pdict: self.innerboundary = pdict['boundary'] clen = -1 if 'content-length' in self.headers: try: clen = int(self.headers['content-length']) except ValueError: pass if maxlen and clen > maxlen: raise ValueError, 'Maximum content length exceeded' self.length = clen self.list = self.file = None self.done = 0 if ctype == 'application/x-www-form-urlencoded': self.read_urlencoded() elif ctype[:10] == 'multipart/': self.read_multi(environ, keep_blank_values, strict_parsing) else: self.read_single() def __repr__(self): """Return a printable representation.""" return "FieldStorage(%r, %r, %r)" % ( self.name, self.filename, self.value) def __iter__(self): return iter(self.keys()) def __getattr__(self, name): if name != 'value': raise AttributeError, name if self.file: self.file.seek(0) value = self.file.read() self.file.seek(0) elif self.list is not None: value = self.list else: value = None return value def __getitem__(self, key): """Dictionary style indexing.""" if self.list is None: raise TypeError, "not indexable" found = [] for item in self.list: if item.name == key: found.append(item) if not found: raise KeyError, key if len(found) == 1: return found[0] else: return found def getvalue(self, key, default=None): """Dictionary style get() method, including 'value' lookup.""" if key in self: value = self[key] if type(value) is type([]): return map(attrgetter('value'), value) else: return value.value else: return default def getfirst(self, key, default=None): """ Return the first value received.""" if key in self: value = self[key] if type(value) is type([]): return value[0].value else: return value.value else: return default def getlist(self, key): """ Return list of received values.""" if key in self: value = self[key] if type(value) is type([]): return map(attrgetter('value'), value) else: return [value.value] else: return [] def keys(self): """Dictionary style keys() method.""" if self.list is None: raise TypeError, "not indexable" return list(set(item.name for item in self.list)) def has_key(self, key): """Dictionary style has_key() method.""" if self.list is None: raise TypeError, "not indexable" return any(item.name == key for item in self.list) def __contains__(self, key): """Dictionary style __contains__ method.""" if self.list is None: raise TypeError, "not indexable" return any(item.name == key for item in self.list) def __len__(self): """Dictionary style len(x) support.""" return len(self.keys()) def __nonzero__(self): return bool(self.list) def read_urlencoded(self): """Internal: read data in query string format.""" qs = self.fp.read(self.length) if self.qs_on_post: qs += '&' + self.qs_on_post self.list = list = [] for key, value in urlparse.parse_qsl(qs, self.keep_blank_values, self.strict_parsing): list.append(MiniFieldStorage(key, value)) self.skip_lines() FieldStorageClass = None def read_multi(self, environ, keep_blank_values, strict_parsing): """Internal: read a part that is itself multipart.""" ib = self.innerboundary if not valid_boundary(ib): raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,) self.list = [] if self.qs_on_post: for key, value in urlparse.parse_qsl(self.qs_on_post, self.keep_blank_values, self.strict_parsing): self.list.append(MiniFieldStorage(key, value)) FieldStorageClass = None klass = self.FieldStorageClass or self.__class__ part = klass(self.fp, {}, ib, environ, keep_blank_values, strict_parsing) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = klass(self.fp, headers, ib, environ, keep_blank_values, strict_parsing) self.list.append(part) self.skip_lines() def read_single(self): """Internal: read an atomic part.""" if self.length >= 0: self.read_binary() self.skip_lines() else: self.read_lines() self.file.seek(0) bufsize = 8*1024 # I/O buffering size for copy to file def read_binary(self): """Internal: read binary data.""" self.file = self.make_file('b') todo = self.length if todo >= 0: while todo > 0: data = self.fp.read(min(todo, self.bufsize)) if not data: self.done = -1 break self.file.write(data) todo = todo - len(data) def read_lines(self): """Internal: read lines until EOF or outerboundary.""" self.file = self.__file = StringIO() if self.outerboundary: self.read_lines_to_outerboundary() else: self.read_lines_to_eof() def __write(self, line): if self.__file is not None: if self.__file.tell() + len(line) > 1000: self.file = self.make_file('') self.file.write(self.__file.getvalue()) self.__file = None self.file.write(line) def read_lines_to_eof(self): """Internal: read lines until EOF.""" while 1: line = self.fp.readline(1<<16) if not line: self.done = -1 break self.__write(line) def read_lines_to_outerboundary(self): """Internal: read lines until outerboundary.""" next = "--" + self.outerboundary last = next + "--" delim = "" last_line_lfend = True while 1: line = self.fp.readline(1<<16) if not line: self.done = -1 break if line[:2] == "--" and last_line_lfend: strippedline = line.strip() if strippedline == next: break if strippedline == last: self.done = 1 break odelim = delim if line[-2:] == "\r\n": delim = "\r\n" line = line[:-2] last_line_lfend = True elif line[-1] == "\n": delim = "\n" line = line[:-1] last_line_lfend = True else: delim = "" last_line_lfend = False self.__write(odelim + line) def skip_lines(self): """Internal: skip lines until outer boundary if defined.""" if not self.outerboundary or self.done: return next = "--" + self.outerboundary last = next + "--" last_line_lfend = True while 1: line = self.fp.readline(1<<16) if not line: self.done = -1 break if line[:2] == "--" and last_line_lfend: strippedline = line.strip() if strippedline == next: break if strippedline == last: self.done = 1 break last_line_lfend = line.endswith('\n') def make_file(self, binary=None): """Overridable: return a readable & writable file. The file will be used as follows: - data is written to it - seek(0) - data is read from it The 'binary' argument is unused -- the file is always opened in binary mode. This version opens a temporary file for reading and writing, and immediately deletes (unlinks) it. The trick (on Unix!) is that the file can still be used, but it can't be opened by another process, and it will automatically be deleted when it is closed or when the current process terminates. If you want a more permanent file, you derive a class which overrides this method. If you want a visible temporary file that is nevertheless automatically deleted when the script terminates, try defining a __del__ method in a derived class which unlinks the temporary files you have created. """ import tempfile return tempfile.TemporaryFile("w+b") # Backwards Compatibility Classes # =============================== class FormContentDict(UserDict.UserDict): """Form content as dictionary with a list of values per field. form = FormContentDict() form[key] -> [value, value, ...] key in form -> Boolean form.keys() -> [key, key, ...] form.values() -> [[val, val, ...], [val, val, ...], ...] form.items() -> [(key, [val, val, ...]), (key, [val, val, ...]), ...] form.dict == {key: [val, val, ...], ...} """ def __init__(self, environ=os.environ, keep_blank_values=0, strict_parsing=0): self.dict = self.data = parse(environ=environ, keep_blank_values=keep_blank_values, strict_parsing=strict_parsing) self.query_string = environ['QUERY_STRING'] class SvFormContentDict(FormContentDict): """Form content as dictionary expecting a single value per field. If you only expect a single value for each field, then form[key] will return that single value. It will raise an IndexError if that expectation is not true. If you expect a field to have possible multiple values, than you can use form.getlist(key) to get all of the values. values() and items() are a compromise: they return single strings where there is a single value, and lists of strings otherwise. """ def __getitem__(self, key): if len(self.dict[key]) > 1: raise IndexError, 'expecting a single value' return self.dict[key][0] def getlist(self, key): return self.dict[key] def values(self): result = [] for value in self.dict.values(): if len(value) == 1: result.append(value[0]) else: result.append(value) return result def items(self): result = [] for key, value in self.dict.items(): if len(value) == 1: result.append((key, value[0])) else: result.append((key, value)) return result class InterpFormContentDict(SvFormContentDict): """This class is present for backwards compatibility only.""" def __getitem__(self, key): v = SvFormContentDict.__getitem__(self, key) if v[0] in '0123456789+-.': try: return int(v) except ValueError: try: return float(v) except ValueError: pass return v.strip() def values(self): result = [] for key in self.keys(): try: result.append(self[key]) except IndexError: result.append(self.dict[key]) return result def items(self): result = [] for key in self.keys(): try: result.append((key, self[key])) except IndexError: result.append((key, self.dict[key])) return result class FormContent(FormContentDict): """This class is present for backwards compatibility only.""" def values(self, key): if key in self.dict :return self.dict[key] else: return None def indexed_value(self, key, location): if key in self.dict: if len(self.dict[key]) > location: return self.dict[key][location] else: return None else: return None def value(self, key): if key in self.dict: return self.dict[key][0] else: return None def length(self, key): return len(self.dict[key]) def stripped(self, key): if key in self.dict: return self.dict[key][0].strip() else: return None def pars(self): return self.dict # Test/debug code # =============== def test(environ=os.environ): """Robust test CGI script, usable as main program. Write minimal HTTP headers and dump all information provided to the script in HTML form. """ print "Content-type: text/html" print sys.stderr = sys.stdout try: form = FieldStorage() # Replace with other classes to test those print_directory() print_arguments() print_form(form) print_environ(environ) print_environ_usage() def f(): exec "testing print_exception() -- italics?" def g(f=f): f() print "

What follows is a test, not an actual exception:

" g() except: print_exception() print "

Second try with a small maxlen...

" global maxlen maxlen = 50 try: form = FieldStorage() # Replace with other classes to test those print_directory() print_arguments() print_form(form) print_environ(environ) except: print_exception() def print_exception(type=None, value=None, tb=None, limit=None): if type is None: type, value, tb = sys.exc_info() import traceback print print "

Traceback (most recent call last):

" list = traceback.format_tb(tb, limit) + \ traceback.format_exception_only(type, value) print "
%s%s
" % ( escape("".join(list[:-1])), escape(list[-1]), ) del tb def print_environ(environ=os.environ): """Dump the shell environment as HTML.""" keys = environ.keys() keys.sort() print print "

Shell Environment:

" print "
" for key in keys: print "
", escape(key), "
", escape(environ[key]) print "
" print def print_form(form): """Dump the contents of a form as HTML.""" keys = form.keys() keys.sort() print print "

Form Contents:

" if not keys: print "

No form fields." print "

" for key in keys: print "
" + escape(key) + ":", value = form[key] print "" + escape(repr(type(value))) + "" print "
" + escape(repr(value)) print "
" print def print_directory(): """Dump the current directory as HTML.""" print print "

Current Working Directory:

" try: pwd = os.getcwd() except os.error, msg: print "os.error:", escape(str(msg)) else: print escape(pwd) print def print_arguments(): print print "

Command Line Arguments:

" print print sys.argv print def print_environ_usage(): """Dump a list of environment variables used by CGI as HTML.""" print """

These environment variables could have been set:

In addition, HTTP headers sent by the server may be passed in the environment as well. Here are some common variable names: """ # Utilities # ========= def escape(s, quote=None): '''Replace special characters "&", "<" and ">" to HTML-safe sequences. If the optional flag quote is true, the quotation mark character (") is also translated.''' s = s.replace("&", "&") # Must be done first! s = s.replace("<", "<") s = s.replace(">", ">") if quote: s = s.replace('"', """) return s def valid_boundary(s, _vb_pattern="^[ -~]{0,200}[!-~]$"): import re return re.match(_vb_pattern, s) # Invoke mainline # =============== # Call test() when this file is run as a script (not imported as a module) if __name__ == '__main__': test()