(gt="Grammar.txt", gp=None,
                 save=True, force=False, logger=None)
return g
Load the grammar (maybe from a pickle).
Load the grammar (maybe from a pickle).
Load the grammar ( maybe from a pickle ) .
def load_grammar(gt="Grammar.txt", gp=None,
                 save=True, force=False, logger=None):
    """Load the grammar (maybe from a pickle)."""
    if logger is None:
        logger = logging.getLogger()
    gp = _generate_pickle_name(gt) if gp is None else gp
    if force or not _newer(gp, gt):
        logger.info("Generating grammar tables from %s", gt)
        g = pgen.generate_grammar(gt)
        if save:
            logger.info("Writing grammar tables to %s", gp)
            try:
                g.dump(gp)
            except OSError as e:
                logger.info("Writing failed: %s", e)
    else:
        g = grammar.Grammar()
        g.load(gp)
    return g
def load_grammar ( gt = "Grammar.txt" , gp = None , save = True , force = False , logger = None ) : if logger is None : logger = logging . getLogger ( ) gp = _generate_pickle_name ( gt ) if gp is None else gp if force or not _newer ( gp , gt ) : logger . info ( "Generating grammar tables from %s" , gt ) g = pgen . generate_grammar ( gt ) if save : logger . info ( "Writing grammar tables to %s" , gp ) try : g . dump ( gp ) except OSError as e : logger . info ( "Writing failed: %s" , e ) else : g = grammar . Grammar ( ) g . load ( gp ) return g