Back to index

python3.2  3.2.2
Classes | Functions | Variables
lib2to3.pgen2.driver Namespace Reference

Classes

class  Driver

Functions

def generate_lines
def load_grammar
def _newer

Variables

string __author__ = "Guido van Rossum <guido@python.org>"
list __all__ = ["Driver", "load_grammar"]

Function Documentation

def lib2to3.pgen2.driver._newer (   a,
  b 
) [private]
Inquire whether file a was written since file b.

Definition at line 141 of file driver.py.

00141 
00142 def _newer(a, b):
00143     """Inquire whether file a was written since file b."""
00144     if not os.path.exists(a):
00145         return False
00146     if not os.path.exists(b):
00147         return True
00148     return os.path.getmtime(a) >= os.path.getmtime(b)

Here is the caller graph for this function:

Generator that behaves like readline without using StringIO.

Definition at line 108 of file driver.py.

00108 
00109 def generate_lines(text):
00110     """Generator that behaves like readline without using StringIO."""
00111     for line in text.splitlines(True):
00112         yield line
00113     while True:
00114         yield ""
00115 

Here is the call graph for this function:

Here is the caller graph for this function:

def lib2to3.pgen2.driver.load_grammar (   gt = "Grammar.txt",
  gp = None,
  save = True,
  force = False,
  logger = None 
)
Load the grammar (maybe from a pickle).

Definition at line 117 of file driver.py.

00117 
00118                  save=True, force=False, logger=None):
00119     """Load the grammar (maybe from a pickle)."""
00120     if logger is None:
00121         logger = logging.getLogger()
00122     if gp is None:
00123         head, tail = os.path.splitext(gt)
00124         if tail == ".txt":
00125             tail = ""
00126         gp = head + tail + ".".join(map(str, sys.version_info)) + ".pickle"
00127     if force or not _newer(gp, gt):
00128         logger.info("Generating grammar tables from %s", gt)
00129         g = pgen.generate_grammar(gt)
00130         if save:
00131             logger.info("Writing grammar tables to %s", gp)
00132             try:
00133                 g.dump(gp)
00134             except IOError as e:
00135                 logger.info("Writing failed:"+str(e))
00136     else:
00137         g = grammar.Grammar()
00138         g.load(gp)
00139     return g
00140 

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 16 of file driver.py.

string lib2to3.pgen2.driver.__author__ = "Guido van Rossum <guido@python.org>"

Definition at line 14 of file driver.py.