/usr/lib64/python2.6
NameSizeModeActions
bsddb/-0755rm
compiler/-0755rm
config/-0755rm
ctypes/-0755rm
curses/-0755rm
Demo/-0755rm
distutils/-0755rm
Doc/-0755rm
email/-0755rm
encodings/-0755rm
hotshot/-0755rm
idlelib/-0755rm
json/-0755rm
lib-dynload/-0755rm
lib-tk/-0755rm
lib2to3/-0755rm
logging/-0755rm
multiprocessing/-0755rm
plat-linux2/-0755rm
site-packages/-0755rm
sqlite3/-0755rm
test/-0755rm
Tools/-0755rm
wsgiref/-0755rm
xml/-0755rm
abc.py70340644editdlrm
abc.pyc60710644editdlrm
abc.pyo60130644editdlrm
aifc.py331880644editdlrm
aifc.pyc295640644editdlrm
aifc.pyo295640644editdlrm
anydbm.py26200644editdlrm
anydbm.pyc27750644editdlrm
anydbm.pyo27750644editdlrm
ast.py113470644editdlrm
ast.pyc127800644editdlrm
ast.pyo127800644editdlrm
asynchat.py114020644editdlrm
asynchat.pyc87370644editdlrm
asynchat.pyo87370644editdlrm
asyncore.py200610644editdlrm
asyncore.pyc184520644editdlrm
asyncore.pyo184520644editdlrm
atexit.py17050644editdlrm
atexit.pyc22150644editdlrm
atexit.pyo22150644editdlrm
audiodev.py75970644editdlrm
audiodev.pyc85370644editdlrm
audiodev.pyo85370644editdlrm
base64.py113350755editdlrm
base64.pyc110030644editdlrm
base64.pyo110030644editdlrm
BaseHTTPServer.py219740644editdlrm
BaseHTTPServer.pyc215750644editdlrm
BaseHTTPServer.pyo215750644editdlrm
Bastion.py57440644editdlrm
Bastion.pyc66670644editdlrm
Bastion.pyo66670644editdlrm
bdb.py205970644editdlrm
bdb.pyc185670644editdlrm
bdb.pyo185670644editdlrm
binhex.py148780644editdlrm
binhex.pyc158750644editdlrm
binhex.pyo158750644editdlrm
bisect.py26620644editdlrm
bisect.pyc31730644editdlrm
bisect.pyo31730644editdlrm
calendar.py231100644editdlrm
calendar.pyc281650644editdlrm
calendar.pyo281650644editdlrm
cgi.py344780755editdlrm
cgi.pyc328180644editdlrm
cgi.pyo328180644editdlrm
CGIHTTPServer.py127730644editdlrm
CGIHTTPServer.pyc108200644editdlrm
CGIHTTPServer.pyo108200644editdlrm
cgitb.py121550644editdlrm
cgitb.pyc124610644editdlrm
cgitb.pyo124610644editdlrm
chunk.py53720644editdlrm
chunk.pyc56450644editdlrm
chunk.pyo56450644editdlrm
cmd.py149620644editdlrm
cmd.pyc139540644editdlrm
cmd.pyo139540644editdlrm
code.py102170644editdlrm
code.pyc104270644editdlrm
code.pyo104270644editdlrm
codecs.py352660644editdlrm
codecs.pyc367210644editdlrm
codecs.pyo367210644editdlrm
codeop.py59990644editdlrm
codeop.pyc66360644editdlrm
codeop.pyo66360644editdlrm
collections.py137300644editdlrm
collections.pyc144620644editdlrm
collections.pyo144090644editdlrm
colorsys.py34590644editdlrm
colorsys.pyc40410644editdlrm
colorsys.pyo40410644editdlrm
commands.py25430644editdlrm
commands.pyc24890644editdlrm
commands.pyo24890644editdlrm
compileall.py52850644editdlrm
compileall.pyc49970644editdlrm
compileall.pyo49970644editdlrm
ConfigParser.py259890644editdlrm
ConfigParser.pyc238650644editdlrm
ConfigParser.pyo238650644editdlrm
contextlib.py41360644editdlrm
contextlib.pyc41510644editdlrm
contextlib.pyo41510644editdlrm
Cookie.py250540644editdlrm
Cookie.pyc221450644editdlrm
Cookie.pyo221450644editdlrm
cookielib.py647260644editdlrm
cookielib.pyc553700644editdlrm
cookielib.pyo551790644editdlrm
copy.py111770644editdlrm
copy.pyc116750644editdlrm
copy.pyo115790644editdlrm
copy_reg.py68000644editdlrm
copy_reg.pyc51780644editdlrm
copy_reg.pyo51320644editdlrm
cProfile.py63370755editdlrm
cProfile.pyc62390644editdlrm
cProfile.pyo62390644editdlrm
crypt.py22290644editdlrm
crypt.pyc30550644editdlrm
crypt.pyo30550644editdlrm
csv.py157300644editdlrm
csv.pyc132260644editdlrm
csv.pyo132260644editdlrm
dbhash.py5350644editdlrm
dbhash.pyc7600644editdlrm
dbhash.pyo7600644editdlrm
decimal.py1992730644editdlrm
decimal.pyc1556810644editdlrm
decimal.pyo1556150644editdlrm
difflib.py810800644editdlrm
difflib.pyc611930644editdlrm
difflib.pyo611390644editdlrm
dircache.py11260644editdlrm
dircache.pyc15840644editdlrm
dircache.pyo15840644editdlrm
dis.py64490644editdlrm
dis.pyc63660644editdlrm
dis.pyo63660644editdlrm
doctest.py1015160644editdlrm
doctest.pyc809940644editdlrm
doctest.pyo807060644editdlrm
DocXMLRPCServer.py105990644editdlrm
DocXMLRPCServer.pyc99570644editdlrm
DocXMLRPCServer.pyo98490644editdlrm
dumbdbm.py88200644editdlrm
dumbdbm.pyc65850644editdlrm
dumbdbm.pyo65850644editdlrm
dummy_thread.py44180644editdlrm
dummy_thread.pyc54130644editdlrm
dummy_thread.pyo54130644editdlrm
dummy_threading.py28040644editdlrm
dummy_threading.pyc12970644editdlrm
dummy_threading.pyo12970644editdlrm
filecmp.py94700644editdlrm
filecmp.pyc96320644editdlrm
filecmp.pyo96320644editdlrm
fileinput.py141430644editdlrm
fileinput.pyc149280644editdlrm
fileinput.pyo149280644editdlrm
fnmatch.py32390644editdlrm
fnmatch.pyc35790644editdlrm
fnmatch.pyo35790644editdlrm
formatter.py149110644editdlrm
formatter.pyc193030644editdlrm
formatter.pyo193030644editdlrm
fpformat.py46990644editdlrm
fpformat.pyc47350644editdlrm
fpformat.pyo47350644editdlrm
fractions.py200730644editdlrm
fractions.pyc181190644editdlrm
fractions.pyo181190644editdlrm
ftplib.py291970644editdlrm
ftplib.pyc285030644editdlrm
ftplib.pyo285030644editdlrm
functools.py21620644editdlrm
functools.pyc19270644editdlrm
functools.pyo19270644editdlrm
genericpath.py30200644editdlrm
genericpath.pyc32920644editdlrm
genericpath.pyo32920644editdlrm
getopt.py73280644editdlrm
getopt.pyc67300644editdlrm
getopt.pyo66830644editdlrm
getpass.py55340644editdlrm
getpass.pyc47540644editdlrm
getpass.pyo47540644editdlrm
gettext.py199680644editdlrm
gettext.pyc157600644editdlrm
gettext.pyo157600644editdlrm
glob.py22490644editdlrm
glob.pyc24090644editdlrm
glob.pyo24090644editdlrm
gzip.py167540644editdlrm
gzip.pyc143860644editdlrm
gzip.pyo143860644editdlrm
hashlib.py44270644editdlrm
hashlib.pyc39810644editdlrm
hashlib.pyo39810644editdlrm
heapq.py159950644editdlrm
heapq.pyc126940644editdlrm
heapq.pyo126940644editdlrm
hmac.py45310644editdlrm
hmac.pyc45090644editdlrm
hmac.pyo45090644editdlrm
htmlentitydefs.py180540644editdlrm
htmlentitydefs.pyc63710644editdlrm
htmlentitydefs.pyo63710644editdlrm
htmllib.py128690644editdlrm
htmllib.pyc203840644editdlrm
htmllib.pyo203840644editdlrm
HTMLParser.py135760644editdlrm
HTMLParser.pyc122580644editdlrm
HTMLParser.pyo119500644editdlrm
httplib.py487970644editdlrm
httplib.pyc377320644editdlrm
httplib.pyo375360644editdlrm
ihooks.py174520644editdlrm
ihooks.pyc208370644editdlrm
ihooks.pyo207580644editdlrm
imaplib.py477710644editdlrm
imaplib.pyc452250644editdlrm
imaplib.pyo424750644editdlrm
imghdr.py35440644editdlrm
imghdr.pyc49050644editdlrm
imghdr.pyo49050644editdlrm
imputil.py260090644editdlrm
imputil.pyc160370644editdlrm
imputil.pyo158650644editdlrm
inspect.py381890644editdlrm
inspect.pyc371650644editdlrm
inspect.pyo371650644editdlrm
io.py661650644editdlrm
io.pyc630420644editdlrm
io.pyo630420644editdlrm
keyword.py19970755editdlrm
keyword.pyc21170644editdlrm
keyword.pyo21170644editdlrm
linecache.py41280644editdlrm
linecache.pyc32680644editdlrm
linecache.pyo32680644editdlrm
locale.py826740644editdlrm
locale.pyc466760644editdlrm
locale.pyo466760644editdlrm
macpath.py62530644editdlrm
macpath.pyc77070644editdlrm
macpath.pyo77070644editdlrm
macurl2path.py32750644editdlrm
macurl2path.pyc28250644editdlrm
macurl2path.pyo28250644editdlrm
mailbox.py758240644editdlrm
mailbox.pyc760690644editdlrm
mailbox.pyo760200644editdlrm
mailcap.py84020644editdlrm
mailcap.pyc80790644editdlrm
mailcap.pyo80790644editdlrm
markupbase.py143500644editdlrm
markupbase.pyc94640644editdlrm
markupbase.pyo92700644editdlrm
md5.py4100644editdlrm
md5.pyc3780644editdlrm
md5.pyo3780644editdlrm
mhlib.py334340644editdlrm
mhlib.pyc341370644editdlrm
mhlib.pyo341370644editdlrm
mimetools.py71680644editdlrm
mimetools.pyc83200644editdlrm
mimetools.pyo83200644editdlrm
mimetypes.py188220644editdlrm
mimetypes.pyc168720644editdlrm
mimetypes.pyo168720644editdlrm
MimeWriter.py64820644editdlrm
MimeWriter.pyc73830644editdlrm
MimeWriter.pyo73830644editdlrm
mimify.py150240755editdlrm
mimify.pyc122190644editdlrm
mimify.pyo122190644editdlrm
modulefinder.py242830644editdlrm
modulefinder.pyc190070644editdlrm
modulefinder.pyo189190644editdlrm
multifile.py48200644editdlrm
multifile.pyc54790644editdlrm
multifile.pyo54350644editdlrm
mutex.py18660644editdlrm
mutex.pyc25260644editdlrm
mutex.pyo25260644editdlrm
netrc.py41110644editdlrm
netrc.pyc36020644editdlrm
netrc.pyo36020644editdlrm
new.py7060644editdlrm
new.pyc9100644editdlrm
new.pyo9100644editdlrm
nntplib.py214700644editdlrm
nntplib.pyc211790644editdlrm
nntplib.pyo211790644editdlrm
ntpath.py177520644editdlrm
ntpath.pyc116200644editdlrm
ntpath.pyo115730644editdlrm
nturl2path.py22390644editdlrm
nturl2path.pyc17770644editdlrm
nturl2path.pyo17770644editdlrm
numbers.py102710644editdlrm
numbers.pyc139640644editdlrm
numbers.pyo139640644editdlrm
opcode.py52480644editdlrm
opcode.pyc59170644editdlrm
opcode.pyo59170644editdlrm
optparse.py608490644editdlrm
optparse.pyc542390644editdlrm
optparse.pyo541570644editdlrm
ordereddict.py360644editdlrm
ordereddict.pyc1850644editdlrm
ordereddict.pyo1850644editdlrm
os.py258020644editdlrm
os.pyc258080644editdlrm
os.pyo258080644editdlrm
os2emxpath.py46030644editdlrm
os2emxpath.pyc45360644editdlrm
os2emxpath.pyo45360644editdlrm
pdb.doc78990644editdlrm
pdb.py453330755editdlrm
pdb.pyc438130644editdlrm
pdb.pyo438130644editdlrm
pickle.py448110644editdlrm
pickle.pyc386450644editdlrm
pickle.pyo384400644editdlrm
pickletools.py743480644editdlrm
pickletools.pyc571430644editdlrm
pickletools.pyo562460644editdlrm
pipes.py96470644editdlrm
pipes.pyc94600644editdlrm
pipes.pyo94600644editdlrm
pkgutil.py200010644editdlrm
pkgutil.pyc190200644editdlrm
pkgutil.pyo190200644editdlrm
platform.py526300755editdlrm
platform.pyc387970644editdlrm
platform.pyo387970644editdlrm
plistlib.py158060644editdlrm
plistlib.pyc200500644editdlrm
plistlib.pyo199600644editdlrm
popen2.py84160644editdlrm
popen2.pyc90640644editdlrm
popen2.pyo90200644editdlrm
poplib.py128250644editdlrm
poplib.pyc134180644editdlrm
poplib.pyo134180644editdlrm
posixfile.py80030644editdlrm
posixfile.pyc77240644editdlrm
posixfile.pyo77240644editdlrm
posixpath.py131190644editdlrm
posixpath.pyc111880644editdlrm
posixpath.pyo111880644editdlrm
pprint.py119320644editdlrm
pprint.pyc103940644editdlrm
pprint.pyo102190644editdlrm
profile.py235100755editdlrm
profile.pyc166800644editdlrm
profile.pyo164350644editdlrm
pstats.py273100644editdlrm
pstats.pyc253400644editdlrm
pstats.pyo253400644editdlrm
pty.py48690644editdlrm
pty.pyc49190644editdlrm
pty.pyo49190644editdlrm
pyclbr.py132820644editdlrm
pyclbr.pyc97320644editdlrm
pyclbr.pyo97320644editdlrm
pydoc.py924320755editdlrm
pydoc.pyc910520644editdlrm
pydoc.pyo909840644editdlrm
pydoc_topics.py4231260644editdlrm
pydoc_topics.pyc4075880644editdlrm
pydoc_topics.pyo4075880644editdlrm
py_compile.py56330644editdlrm
py_compile.pyc65540644editdlrm
py_compile.pyo65540644editdlrm
Queue.py85740644editdlrm
Queue.pyc94470644editdlrm
Queue.pyo94470644editdlrm
quopri.py69720755editdlrm
quopri.pyc66880644editdlrm
quopri.pyo66880644editdlrm
random.py319660644editdlrm
random.pyc251060644editdlrm
random.pyo251060644editdlrm
re.py129660644editdlrm
re.pyc131640644editdlrm
re.pyo131640644editdlrm
repr.py42960644editdlrm
repr.pyc54340644editdlrm
repr.pyo54340644editdlrm
rexec.py201520644editdlrm
rexec.pyc242200644editdlrm
rexec.pyo242200644editdlrm
rfc822.py332950644editdlrm
rfc822.pyc321100644editdlrm
rfc822.pyo321100644editdlrm
rlcompleter.py58660644editdlrm
rlcompleter.pyc60730644editdlrm
rlcompleter.pyo60730644editdlrm
robotparser.py70140644editdlrm
robotparser.pyc78520644editdlrm
robotparser.pyo78520644editdlrm
runpy.py54130644editdlrm
runpy.pyc39790644editdlrm
runpy.pyo39790644editdlrm
sched.py50910644editdlrm
sched.pyc50050644editdlrm
sched.pyo50050644editdlrm
sets.py190500644editdlrm
sets.pyc169970644editdlrm
sets.pyo169970644editdlrm
sgmllib.py178840644editdlrm
sgmllib.pyc155980644editdlrm
sgmllib.pyo155980644editdlrm
sha.py4450644editdlrm
sha.pyc4210644editdlrm
sha.pyo4210644editdlrm
shelve.py80780644editdlrm
shelve.pyc102960644editdlrm
shelve.pyo102960644editdlrm
shlex.py111370644editdlrm
shlex.pyc77100644editdlrm
shlex.pyo77100644editdlrm
shutil.py86320644editdlrm
shutil.pyc95550644editdlrm
shutil.pyo95550644editdlrm
SimpleHTTPServer.py74220644editdlrm
SimpleHTTPServer.pyc77660644editdlrm
SimpleHTTPServer.pyo77660644editdlrm
SimpleXMLRPCServer.py219920644editdlrm
SimpleXMLRPCServer.pyc196330644editdlrm
SimpleXMLRPCServer.pyo196330644editdlrm
site.py191870644editdlrm
site.pyc188250644editdlrm
site.pyo188250644editdlrm
smtpd.py189200755editdlrm
smtpd.pyc161880644editdlrm
smtpd.pyo161880644editdlrm
smtplib.py309240755editdlrm
smtplib.pyc297370644editdlrm
smtplib.pyo297370644editdlrm
sndhdr.py59730644editdlrm
sndhdr.pyc74200644editdlrm
sndhdr.pyo74200644editdlrm
socket.py201490644editdlrm
socket.pyc161290644editdlrm
socket.pyo160440644editdlrm
SocketServer.py223260644editdlrm
SocketServer.pyc231430644editdlrm
SocketServer.pyo231430644editdlrm
sre.py3840644editdlrm
sre.pyc5190644editdlrm
sre.pyo5190644editdlrm
sre_compile.py165070644editdlrm
sre_compile.pyc114830644editdlrm
sre_compile.pyo113700644editdlrm
sre_constants.py71370644editdlrm
sre_constants.pyc60930644editdlrm
sre_constants.pyo60930644editdlrm
sre_parse.py268780644editdlrm
sre_parse.pyc196960644editdlrm
sre_parse.pyo196960644editdlrm
ssl.py166770644editdlrm
ssl.pyc142760644editdlrm
ssl.pyo142760644editdlrm
stat.py17180644editdlrm
stat.pyc27030644editdlrm
stat.pyo27030644editdlrm
statvfs.py8980644editdlrm
statvfs.pyc6200644editdlrm
statvfs.pyo6200644editdlrm
string.py207450644editdlrm
string.pyc200660644editdlrm
string.pyo200660644editdlrm
StringIO.py106210644editdlrm
StringIO.pyc115320644editdlrm
StringIO.pyo115320644editdlrm
stringold.py124490644editdlrm
stringold.pyc125930644editdlrm
stringold.pyo125930644editdlrm
stringprep.py135220644editdlrm
stringprep.pyc145260644editdlrm
stringprep.pyo144520644editdlrm
struct.py820644editdlrm
struct.pyc2390644editdlrm
struct.pyo2390644editdlrm
subprocess.py579450644editdlrm
subprocess.pyc410710644editdlrm
subprocess.pyo410140644editdlrm
sunau.py165370644editdlrm
sunau.pyc180720644editdlrm
sunau.pyo180720644editdlrm
sunaudio.py13990644editdlrm
sunaudio.pyc19970644editdlrm
sunaudio.pyo19970644editdlrm
symbol.py20500755editdlrm
symbol.pyc30250644editdlrm
symbol.pyo30250644editdlrm
symtable.py79110644editdlrm
symtable.pyc126090644editdlrm
symtable.pyo124790644editdlrm
tabnanny.py113390755editdlrm
tabnanny.pyc83330644editdlrm
tabnanny.pyo83330644editdlrm
tarfile.py877860644editdlrm
tarfile.pyc739220644editdlrm
tarfile.pyo739220644editdlrm
telnetlib.py218080644editdlrm
telnetlib.pyc199130644editdlrm
telnetlib.pyo199130644editdlrm
tempfile.py177740644editdlrm
tempfile.pyc195710644editdlrm
tempfile.pyo195710644editdlrm
textwrap.py168890644editdlrm
textwrap.pyc117920644editdlrm
textwrap.pyo117000644editdlrm
this.py10020644editdlrm
this.pyc12410644editdlrm
this.pyo12410644editdlrm
threading.py318080644editdlrm
threading.pyc281520644editdlrm
threading.pyo260800644editdlrm
timeit.py120030644editdlrm
timeit.pyc118270644editdlrm
timeit.pyo118270644editdlrm
toaiff.py31420644editdlrm
toaiff.pyc31340644editdlrm
toaiff.pyo31340644editdlrm
token.py29470755editdlrm
token.pyc38400644editdlrm
token.pyo38400644editdlrm
tokenize.py163260644editdlrm
tokenize.pyc140180644editdlrm
tokenize.pyo139250644editdlrm
trace.py303250644editdlrm
trace.pyc230510644editdlrm
trace.pyo229890644editdlrm
traceback.py112110644editdlrm
traceback.pyc116770644editdlrm
traceback.pyo116770644editdlrm
tty.py8790644editdlrm
tty.pyc13170644editdlrm
tty.pyo13170644editdlrm
types.py23230644editdlrm
types.pyc26200644editdlrm
types.pyo26200644editdlrm
unittest.py311570644editdlrm
unittest.pyc348620644editdlrm
unittest.pyo348620644editdlrm
urllib.py590220644editdlrm
urllib.pyc513480644editdlrm
urllib.pyo512540644editdlrm
urllib2.py508660644editdlrm
urllib2.pyc458130644editdlrm
urllib2.pyo457190644editdlrm
urlparse.py156180644editdlrm
urlparse.pyc147770644editdlrm
urlparse.pyo147770644editdlrm
user.py16270644editdlrm
user.pyc17360644editdlrm
user.pyo17360644editdlrm
UserDict.py57780644editdlrm
UserDict.pyc88920644editdlrm
UserDict.pyo88920644editdlrm
UserList.py36440644editdlrm
UserList.pyc66030644editdlrm
UserList.pyo66030644editdlrm
UserString.py96910755editdlrm
UserString.pyc149220644editdlrm
UserString.pyo149220644editdlrm
uu.py59420755editdlrm
uu.pyc42370644editdlrm
uu.pyo42370644editdlrm
uuid.py209440644editdlrm
uuid.pyc212790644editdlrm
uuid.pyo212790644editdlrm
warnings.py141720644editdlrm
warnings.pyc130420644editdlrm
warnings.pyo122050644editdlrm
wave.py179520644editdlrm
wave.pyc194360644editdlrm
wave.pyo194360644editdlrm
weakref.py100870644editdlrm
weakref.pyc133750644editdlrm
weakref.pyo133750644editdlrm
webbrowser.py210730644editdlrm
webbrowser.pyc187550644editdlrm
webbrowser.pyo187080644editdlrm
whichdb.py33530644editdlrm
whichdb.pyc22470644editdlrm
whichdb.pyo22470644editdlrm
xdrlib.py55130644editdlrm
xdrlib.pyc91570644editdlrm
xdrlib.pyo91570644editdlrm
xmllib.py348650644editdlrm
xmllib.pyc272740644editdlrm
xmllib.pyo272740644editdlrm
xmlrpclib.py477750644editdlrm
xmlrpclib.pyc414960644editdlrm
xmlrpclib.pyo413130644editdlrm
zipfile.py530920644editdlrm
zipfile.pyc376520644editdlrm
zipfile.pyo376520644editdlrm
_abcoll.py142420644editdlrm
_abcoll.pyc215910644editdlrm
_abcoll.pyo215910644editdlrm
_LWPCookieJar.py65530644editdlrm
_LWPCookieJar.pyc56010644editdlrm
_LWPCookieJar.pyo56010644editdlrm
_MozillaCookieJar.py58090644editdlrm
_MozillaCookieJar.pyc45170644editdlrm
_MozillaCookieJar.pyo44760644editdlrm
_strptime.py197540644editdlrm
_strptime.pyc149660644editdlrm
_strptime.pyo149660644editdlrm
_threading_local.py71140644editdlrm
_threading_local.pyc63850644editdlrm
_threading_local.pyo63850644editdlrm
__future__.py43800644editdlrm
__future__.pyc42330644editdlrm
__future__.pyo42330644editdlrm
__phello__.foo.py640644editdlrm
__phello__.foo.pyc1250644editdlrm
__phello__.foo.pyo1250644editdlrm
Edit: /usr/lib64/python2.6/ast.py (11347B)
# -*- coding: utf-8 -*- """ ast ~~~ The `ast` module helps Python applications to process trees of the Python abstract syntax grammar. The abstract syntax itself might change with each Python release; this module helps to find out programmatically what the current grammar looks like and allows modifications of it. An abstract syntax tree can be generated by passing `ast.PyCF_ONLY_AST` as a flag to the `compile()` builtin function or by using the `parse()` function from this module. The result will be a tree of objects whose classes all inherit from `ast.AST`. A modified abstract syntax tree can be compiled into a Python code object using the built-in `compile()` function. Additionally various helper functions are provided that make working with the trees simpler. The main intention of the helper functions and this module in general is to provide an easy to use interface for libraries that work tightly with the python syntax (template engines for example). :copyright: Copyright 2008 by Armin Ronacher. :license: Python License. """ from _ast import * from _ast import __version__ def parse(expr, filename='', mode='exec'): """ Parse an expression into an AST node. Equivalent to compile(expr, filename, mode, PyCF_ONLY_AST). """ return compile(expr, filename, mode, PyCF_ONLY_AST) def literal_eval(node_or_string): """ Safely evaluate an expression node or a string containing a Python expression. The string or node provided may only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None. """ _safe_names = {'None': None, 'True': True, 'False': False} if isinstance(node_or_string, basestring): node_or_string = parse(node_or_string, mode='eval') if isinstance(node_or_string, Expression): node_or_string = node_or_string.body def _convert(node): if isinstance(node, Str): return node.s elif isinstance(node, Num): return node.n elif isinstance(node, Tuple): return tuple(map(_convert, node.elts)) elif isinstance(node, List): return list(map(_convert, node.elts)) elif isinstance(node, Dict): return dict((_convert(k), _convert(v)) for k, v in zip(node.keys, node.values)) elif isinstance(node, Name): if node.id in _safe_names: return _safe_names[node.id] raise ValueError('malformed string') return _convert(node_or_string) def dump(node, annotate_fields=True, include_attributes=False): """ Return a formatted dump of the tree in *node*. This is mainly useful for debugging purposes. The returned string will show the names and the values for fields. This makes the code impossible to evaluate, so if evaluation is wanted *annotate_fields* must be set to False. Attributes such as line numbers and column offsets are not dumped by default. If this is wanted, *include_attributes* can be set to True. """ def _format(node): if isinstance(node, AST): fields = [(a, _format(b)) for a, b in iter_fields(node)] rv = '%s(%s' % (node.__class__.__name__, ', '.join( ('%s=%s' % field for field in fields) if annotate_fields else (b for a, b in fields) )) if include_attributes and node._attributes: rv += fields and ', ' or ' ' rv += ', '.join('%s=%s' % (a, _format(getattr(node, a))) for a in node._attributes) return rv + ')' elif isinstance(node, list): return '[%s]' % ', '.join(_format(x) for x in node) return repr(node) if not isinstance(node, AST): raise TypeError('expected AST, got %r' % node.__class__.__name__) return _format(node) def copy_location(new_node, old_node): """ Copy source location (`lineno` and `col_offset` attributes) from *old_node* to *new_node* if possible, and return *new_node*. """ for attr in 'lineno', 'col_offset': if attr in old_node._attributes and attr in new_node._attributes \ and hasattr(old_node, attr): setattr(new_node, attr, getattr(old_node, attr)) return new_node def fix_missing_locations(node): """ When you compile a node tree with compile(), the compiler expects lineno and col_offset attributes for every node that supports them. This is rather tedious to fill in for generated nodes, so this helper adds these attributes recursively where not already set, by setting them to the values of the parent node. It works recursively starting at *node*. """ def _fix(node, lineno, col_offset): if 'lineno' in node._attributes: if not hasattr(node, 'lineno'): node.lineno = lineno else: lineno = node.lineno if 'col_offset' in node._attributes: if not hasattr(node, 'col_offset'): node.col_offset = col_offset else: col_offset = node.col_offset for child in iter_child_nodes(node): _fix(child, lineno, col_offset) _fix(node, 1, 0) return node def increment_lineno(node, n=1): """ Increment the line number of each node in the tree starting at *node* by *n*. This is useful to "move code" to a different location in a file. """ if 'lineno' in node._attributes: node.lineno = getattr(node, 'lineno', 0) + n for child in walk(node): if 'lineno' in child._attributes: child.lineno = getattr(child, 'lineno', 0) + n return node def iter_fields(node): """ Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields`` that is present on *node*. """ for field in node._fields: try: yield field, getattr(node, field) except AttributeError: pass def iter_child_nodes(node): """ Yield all direct child nodes of *node*, that is, all fields that are nodes and all items of fields that are lists of nodes. """ for name, field in iter_fields(node): if isinstance(field, AST): yield field elif isinstance(field, list): for item in field: if isinstance(item, AST): yield item def get_docstring(node, clean=True): """ Return the docstring for the given node or None if no docstring can be found. If the node provided does not have docstrings a TypeError will be raised. """ if not isinstance(node, (FunctionDef, ClassDef, Module)): raise TypeError("%r can't have docstrings" % node.__class__.__name__) if node.body and isinstance(node.body[0], Expr) and \ isinstance(node.body[0].value, Str): if clean: import inspect return inspect.cleandoc(node.body[0].value.s) return node.body[0].value.s def walk(node): """ Recursively yield all child nodes of *node*, in no specified order. This is useful if you only want to modify nodes in place and don't care about the context. """ from collections import deque todo = deque([node]) while todo: node = todo.popleft() todo.extend(iter_child_nodes(node)) yield node class NodeVisitor(object): """ A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the `visit` method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are ``'visit_'`` + class name of the node. So a `TryFinally` node visit function would be `visit_TryFinally`. This behavior can be changed by overriding the `visit` method. If no visitor function exists for a node (return value `None`) the `generic_visit` visitor is used instead. Don't use the `NodeVisitor` if you want to apply changes to nodes during traversing. For this a special visitor exists (`NodeTransformer`) that allows modifications. """ def visit(self, node): """Visit a node.""" method = 'visit_' + node.__class__.__name__ visitor = getattr(self, method, self.generic_visit) return visitor(node) def generic_visit(self, node): """Called if no explicit visitor function exists for a node.""" for field, value in iter_fields(node): if isinstance(value, list): for item in value: if isinstance(item, AST): self.visit(item) elif isinstance(value, AST): self.visit(value) class NodeTransformer(NodeVisitor): """ A :class:`NodeVisitor` subclass that walks the abstract syntax tree and allows modification of nodes. The `NodeTransformer` will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is ``None``, the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups (``foo``) to ``data['foo']``:: class RewriteName(NodeTransformer): def visit_Name(self, node): return copy_location(Subscript( value=Name(id='data', ctx=Load()), slice=Index(value=Str(s=node.id)), ctx=node.ctx ), node) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth:`generic_visit` method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this:: node = YourTransformer().visit(node) """ def generic_visit(self, node): for field, old_value in iter_fields(node): old_value = getattr(node, field, None) if isinstance(old_value, list): new_values = [] for value in old_value: if isinstance(value, AST): value = self.visit(value) if value is None: continue elif not isinstance(value, AST): new_values.extend(value) continue new_values.append(value) old_value[:] = new_values elif isinstance(old_value, AST): new_node = self.visit(old_value) if new_node is None: delattr(node, field) else: setattr(node, field, new_node) return node