コード例 #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))