Did I find the right examples for you? yes no

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
Parse the file 'fn' and return two things:

1. The AST tree.
2. A list of lines of the source line (typically used for verbose error
   messages).

        def parse_python_source(fn):
    """Parse the file 'fn' and return two things:

    1. The AST tree.
    2. A list of lines of the source line (typically used for verbose error
       messages).

    """
    # Read the file's contents to return it.
    # Note: we make sure to use universal newlines.
    try:
        contents = open(fn, 'rU').read()
        lines = contents.splitlines()
    except (IOError, OSError), e:
        logging.error("Could not read file '%s'." % fn)
        return None, None

    # Convert the file to an AST.
    try:
        ast = compiler.parse(contents)
    except SyntaxError, e:
        err = '%s:%d: %s' % (fn, e.lineno, e.msg)
        logging.error("Error processing file '%s':\n%s" %
                      (fn, err))
        return None, lines

    return ast, lines
        


src/s/n/snakefood-1.4/lib/python/snakefood/checker.py   snakefood(Download)
 
from snakefood.util import def_ignores, iter_pyfiles
from snakefood.find import parse_python_source, get_ast_imports
from snakefood.find import check_duplicate_imports
from snakefood.astpretty import printAst
 
        # Parse the file.
        ast, lines = parse_python_source(fn)
        if ast is None:
            continue