Back to index

python3.2  3.2.2
Classes | Functions | Variables
unparse Namespace Reference

Classes

class  Unparser

Functions

def interleave
def roundtrip
def testdir
def main

Variables

string INFSTR = "1e"

Function Documentation

def unparse.interleave (   inter,
  f,
  seq 
)
Call f on each item in seq, calling inter() in between.

Definition at line 13 of file unparse.py.

00013 
00014 def interleave(inter, f, seq):
00015     """Call f on each item in seq, calling inter() in between.
00016     """
00017     seq = iter(seq)
00018     try:
00019         f(next(seq))
00020     except StopIteration:
00021         pass
00022     else:
00023         for x in seq:
00024             inter()
00025             f(x)

Here is the caller graph for this function:

def unparse.main (   args)

Definition at line 591 of file unparse.py.

00591 
00592 def main(args):
00593     if args[0] == '--testdir':
00594         for a in args[1:]:
00595             testdir(a)
00596     else:
00597         for a in args:
00598             roundtrip(a)

Here is the call graph for this function:

def unparse.roundtrip (   filename,
  output = sys.stdout 
)

Definition at line 563 of file unparse.py.

00563 
00564 def roundtrip(filename, output=sys.stdout):
00565     with open(filename, "rb") as pyfile:
00566         encoding = tokenize.detect_encoding(pyfile.readline)[0]
00567     with open(filename, "r", encoding=encoding) as pyfile:
00568         source = pyfile.read()
00569     tree = compile(source, filename, "exec", ast.PyCF_ONLY_AST)
00570     Unparser(tree, output)
00571 
00572 

Here is the call graph for this function:

Here is the caller graph for this function:

def unparse.testdir (   a)

Definition at line 573 of file unparse.py.

00573 
00574 def testdir(a):
00575     try:
00576         names = [n for n in os.listdir(a) if n.endswith('.py')]
00577     except OSError:
00578         print("Directory not readable: %s" % a, file=sys.stderr)
00579     else:
00580         for n in names:
00581             fullname = os.path.join(a, n)
00582             if os.path.isfile(fullname):
00583                 output = io.StringIO()
00584                 print('Testing %s' % fullname)
00585                 try:
00586                     roundtrip(fullname, output)
00587                 except Exception as e:
00588                     print('  Failed to compile, exception is %s' % repr(e))
00589             elif os.path.isdir(fullname):
00590                 testdir(fullname)

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 11 of file unparse.py.