コード例 #1
0
    def test_get_includes(self):
        test_file = open(get_file_path("files/function/get_includes.func"))
        test_text = test_file.read()
        test_file.close()
        test_results = ["test1", "test2", "test3", "test4", "test5"]
        function = Function(test_text, "./")

        assert function.get_includes() == test_results
コード例 #2
0
    def test_get_name(self):
        test_file = open(get_file_path("files/function/get_name_args.func"))
        test_text = test_file.read()
        test_file.close()
        test_results = "Name"

        for line in test_text.split("\n"):
            if line != "":
                function = Function(line, "./")
                assert function.get_name() == test_results
コード例 #3
0
    def test_get_name(self):
        test_file = open(get_file_path("files/function/get_name_args.func"))
        test_text = test_file.read()
        test_file.close()
        test_results = "Name"

        for line in test_text.split("\n"):
            if line != "":
                function = Function(line, "./")
                assert function.get_name() == test_results
コード例 #4
0
    def test_get_args(self):
        test_file = open(get_file_path("files/function/get_name_args.func"))
        test_text = test_file.read()
        test_file.close()
        test_results = [[], [["int", "i"]], [], [["int", "i"], ["float", "t"]],
                        [], [["int", "i"], ["std::string", "t"]]]

        n = 0
        for line in test_text.split("\n"):
            if line != "":
                function = Function(line, "./")
                assert function.get_args() == test_results[n]
                n += 1
コード例 #5
0
    def test_get_includes(self):
        test_file = open(get_file_path("files/function/get_includes.func"))
        test_text = test_file.read()
        test_file.close()
        test_results = [
            "test1",
            "test2",
            "test3",
            "test4",
            "test5"
        ]
        function = Function(test_text, "./")

        assert function.get_includes() == test_results
コード例 #6
0
    def test_get_section(self):
        test_file = open(get_file_path("files/function/get_section.func"))
        test_text = test_file.read()
        test_file.close()
        test_results = {
            "test1": "  test1",
            "test2": "  test2",
            "test3": "  test3\n  test3",
            "test4": "  test4",
            "test6": ""
        }
        function = Function(test_text, "./")

        for test in test_results:
            assert function.get_section(test) == test_results[test]
コード例 #7
0
    def test_get_section(self):
        test_file = open(get_file_path("files/function/get_section.func"))
        test_text = test_file.read()
        test_file.close()
        test_results = {
            "test1": "  test1",
            "test2": "  test2",
            "test3": "  test3\n  test3",
            "test4": "  test4",
            "test6": ""
        }
        function = Function(test_text, "./")

        for test in test_results:
            assert function.get_section(test) == test_results[test]
コード例 #8
0
def main(arg_list=None):
    args = vars(parse_args(arg_list))
    Logger.show_log_levels += args["verbose"] - args["quiet"]
    Logger.debug("Log level: {}".format(Logger.show_log_levels))
    Logger.debug("Arguments: {}".format(args))
    auto_functions = [
        Function(open(function_file).read(), get_script_dir())
        for function_file in args["input_files"]
    ]
    Logger.info("Found auto functions: {}".format(
        [func.get_name() for func in auto_functions]))
    cpp_file = open(args["output_cpp"], "w")
    h_file = open(args["output_header"], "w")

    compiled_auto_functions = generate_auto_functions(auto_functions,
                                                      args["output_header"])

    if args["format"]:
        Logger.info("Formatting output files")
        compiled_auto_functions = [
            Formatter(func).get_formatted_text()
            for func in compiled_auto_functions
        ]

    Logger.debug("Writing output files")
    h_file.write(compiled_auto_functions[0])
    cpp_file.write(compiled_auto_functions[1])
    cpp_file.close()
    h_file.close()
    Logger.info("Done :)")
コード例 #9
0
def enumerate_auto_files(path):
    if not path[-1] == "/":
        path += "/"
    auto_function_files = []

    for function_file in glob.glob(os.path.join(path, "*.func")):
        auto_function_files.append(Function(open(function_file).read(), get_script_dir()))
    return auto_function_files
コード例 #10
0
    def test_get_args(self):
        test_file = open(get_file_path("files/function/get_name_args.func"))
        test_text = test_file.read()
        test_file.close()
        test_results = [
            [],
            [["int", "i"]],
            [],
            [["int", "i"], ["float", "t"]],
            [],
            [["int", "i"], ["std::string", "t"]]
        ]

        n = 0
        for line in test_text.split("\n"):
            if line != "":
                function = Function(line, "./")
                assert function.get_args() == test_results[n]
                n += 1
コード例 #11
0
    def test_get_args(self):
        test_file = open(get_file_path("files/function/get_name_args.func"))
        test_text = test_file.read()
        test_file.close()
        test_results = [
            [['CitrusRobot *', 'robot']],
            [['CitrusRobot *', 'robot'], ["int", "i"]],
            [['CitrusRobot *', 'robot']],
            [['CitrusRobot *', 'robot'], ["int", "i"], ["Time", "t"]],
            [['CitrusRobot *', 'robot']],
            [['CitrusRobot *', 'robot'], ["int", "i"], ["Time", "t"]]
        ]

        n = 0
        for line in test_text.split("\n"):
            if line != "":
                function = Function(line, "./")
                assert function.get_args() == test_results[n]
                n += 1