Beispiel #1
0
    def _write_code(self, ctx, code):
        """Writes generated code to file system.

        """
        if code:
            for code, dir_, fpath in code:
                gu.write_file(gu.format_code(ctx, code), dir_, fpath)
Beispiel #2
0
def _generate_from_template(ctx, template):
    """Generates code from a tornado template.

    """
    lu = _HANDLERS[ctx.language].UTILS
    utils.log("GENERATOR = {0} :: generation begins".format(ctx.key))
    code = ctx.get_code(template, lu)
    if code:
        gu.write_file(gu.format_code(ctx, code),
                      lu.get_ontology_directory(ctx),
                      lu.get_module_file_name(template.split('.')[0]))
    utils.log("GENERATOR = {0} :: generation complete".format(ctx.key))
Beispiel #3
0
def _generate_from_parser(ctx, parser_type):
    """Generates code from an ontology parser.

    """
    parser = parser_type()
    if not parser.is_required(ctx):
        utils.log("GENERATOR = {0} :: generation skipped".format(ctx.key))
    else:
        utils.log("GENERATOR = {0} :: generation begins".format(ctx.key))
        parser.execute(ctx)
        for code, dir_, fpath in ctx.code:
            gu.write_file(gu.format_code(ctx, code), dir_, fpath)
        utils.log("GENERATOR = {0} :: generation complete".format(ctx.key))