예제 #1
0
    def add_module(self, ast, parent):
        """
        Adds parsed AST to the model, without doing any optimizations. May be
        called more than once, with different parsed files.

        :param ast: AST of the input file, as returned by
               :func:`bkl.parser.parse_file`.
        """
        logger.info("processing %s", ast.filename)

        submodules = []
        b = Builder(on_submodule=lambda fn, pos: submodules.append((fn, pos)))

        module = b.create_model(ast, parent)

        while submodules:
            sub_filename, sub_pos = submodules[0]
            submodules.pop(0)
            try:
                sub_ast = parse_file(sub_filename)
            except IOError as e:
                if e.filename:
                    msg = "%s: %s" % (e.strerror, e.filename)
                else:
                    msg = e.strerror
                raise Error(msg, pos=sub_pos)
            self.add_module(sub_ast, module)
예제 #2
0
파일: __init__.py 프로젝트: Fooway/bakefile
    def add_module(self, ast, parent):
        """
        Adds parsed AST to the model, without doing any optimizations. May be
        called more than once, with different parsed files.

        :param ast: AST of the input file, as returned by
               :func:`bkl.parser.parse_file`.
        """
        logger.info("processing %s", ast.filename)

        submodules = []
        b = Builder(on_submodule=lambda fn, pos: submodules.append((fn,pos)))

        module = b.create_model(ast, parent)

        while submodules:
            sub_filename, sub_pos = submodules[0]
            submodules.pop(0)
            try:
                sub_ast = parse_file(sub_filename)
            except IOError as e:
                if e.filename:
                    msg = "%s: %s" % (e.strerror, e.filename)
                else:
                    msg = e.strerror
                raise Error(msg, pos=sub_pos)
            self.add_module(sub_ast, module)
예제 #3
0
 def process_file(self, filename):
     """Like :meth:`process()`, but takes filename as its argument."""
     self.process(parse_file(filename))
예제 #4
0
파일: __init__.py 프로젝트: Fooway/bakefile
 def process_file(self, filename):
     """Like :meth:`process()`, but takes filename as its argument."""
     self.process(parse_file(filename))