[Python-checkins] r52864 - sandbox/trunk/2to3/example.py sandbox/trunk/2to3/play.py sandbox/trunk/2to3/pynode.py
guido.van.rossum
python-checkins at python.org
Thu Nov 30 00:19:03 CET 2006
Author: guido.van.rossum
Date: Thu Nov 30 00:19:02 2006
New Revision: 52864
Added:
sandbox/trunk/2to3/example.py (contents, props changed)
Modified:
sandbox/trunk/2to3/play.py
sandbox/trunk/2to3/pynode.py
Log:
Add specific example code.
Run the example by default.
Add __str__ to generic series node.
Don't require Python 2.5.
Added: sandbox/trunk/2to3/example.py
==============================================================================
--- (empty file)
+++ sandbox/trunk/2to3/example.py Thu Nov 30 00:19:02 2006
@@ -0,0 +1 @@
+print (12 + 12)
Modified: sandbox/trunk/2to3/play.py
==============================================================================
--- sandbox/trunk/2to3/play.py (original)
+++ sandbox/trunk/2to3/play.py Thu Nov 30 00:19:02 2006
@@ -3,7 +3,7 @@
"""XXX."""
-from __future__ import with_statement
+##from __future__ import with_statement
__author__ = "Guido van Rossum <guido at python.org>"
@@ -17,23 +17,16 @@
import pynode
-logging.basicConfig(level=logging.INFO)
-
-SAMPLE = """\
-for i in range(10):
- print i
-class C(object, list):
- def f(a, b, c=1, *args, **kwds):
- pass
-"""
+logging.basicConfig(level=logging.WARN)
def main():
gr = driver.load_grammar("Grammar.txt")
dr = driver.Driver(gr, convert=pynode.convert)
-## tree = dr.parse_file("pynode.py", debug=True)
-## print tree
+ tree = dr.parse_file("example.py", debug=True)
+ print tree
+## # Process every imported module
## for name in sys.modules:
## mod = sys.modules[name]
## if mod is None or not hasattr(mod, "__file__"):
@@ -46,21 +39,21 @@
## print >>sys.stderr, "Parsing", fn
## dr.parse_file(fn, debug=True)
- for dir in reversed(sys.path):
- try:
- names = os.listdir(dir)
- except os.error:
- continue
- print >>sys.stderr, "Scanning", dir, "..."
- for name in names:
- if not name.endswith(".py"):
- continue
- print >>sys.stderr, "Parsing", name
- try:
- dr.parse_file(os.path.join(dir, name), debug=True)
- except pgen2.parse.ParseError, err:
- print "ParseError:", err
-
+## # Process every single module on sys.path (but not in packages)
+## for dir in sys.path:
+## try:
+## names = os.listdir(dir)
+## except os.error:
+## continue
+## print >>sys.stderr, "Scanning", dir, "..."
+## for name in names:
+## if not name.endswith(".py"):
+## continue
+## print >>sys.stderr, "Parsing", name
+## try:
+## dr.parse_file(os.path.join(dir, name), debug=True)
+## except pgen2.parse.ParseError, err:
+## print "ParseError:", err
if __name__ == "__main__":
main()
Modified: sandbox/trunk/2to3/pynode.py
==============================================================================
--- sandbox/trunk/2to3/pynode.py (original)
+++ sandbox/trunk/2to3/pynode.py Thu Nov 30 00:19:02 2006
@@ -207,6 +207,8 @@
__slots__ = ["nodes"]
def initseries(self, nodes):
self.nodes = nodes
+ def __str__(self):
+ return " ".join(map(str, self.nodes))
class atom(GenericSeries):
__slots__ = []
More information about the Python-checkins
mailing list