コード例 #1
0
ファイル: please_test.py プロジェクト: parallel-p/please
    def test_clear_tags(self):
        """ Checks command 'clear tags' """

        start_dir = os.getcwd()
        os.chdir("problem_test")

        self.__matcher.add_handler(Template(["add", "tag|tags", "@tags"]),
                                   add_tags, True)
        self.__matcher.matches("add tags tag1 tag2 tag3 tag4".split())

        self.__matcher.add_handler(Template(["clear", "tags"]), clear_tags,
                                   True)
        self.__matcher.matches("clear tags".split())

        saveout = sys.stdout
        sys.stdout = StringIO()

        self.__matcher.add_handler(Template(["show", "tags"]), show_tags, True)
        self.__matcher.matches("show tags".split())

        ttt = sys.stdout.getvalue()
        tags_from_std = ttt.split("\n")[0]
        sys.stdout = saveout

        open_config = package_config.PackageConfig.get_config(
            ignore_cache=True)
        os.chdir(start_dir)
        self.assertEqual(tags_from_std, "")
コード例 #2
0
ファイル: __init__.py プロジェクト: parallel-p/please
def add_creation_operations(matcher, active):
    from please.contest import commands as contest_commands
    from please.template import problem_template_generator
    matcher.add_handler(Template(["create", "problem", "#shortname"]),
            problem_template_generator.generate_problem, active)
    matcher.add_handler(Template(["create", "contest", "#name", "of", "@problems"]),
            contest_commands.command_create_contest, active)
コード例 #3
0
def add_validate_operations(matcher, active):
    from please.tests_answer_generator import tests_answer_generator
    from please.add_source.add_source import add_validator
    for tpl in [["validate|val", "tests"], ["validate"]]:
        matcher.add_handler(
            Template(tpl),
            tests_answer_generator.TestsAndAnswersGenerator().validate, active)
    matcher.add_handler(Template(["set", "validator|val", "$path"]),
                        add_validator, active)
コード例 #4
0
def add_computing_tl_functions(matcher, active):
    from please.auto_TL.auto_tl import set_integer_tl, set_float_tl
    matcher.add_handler(
        Template(["compute", TL_ALIASES]),
        set_float_tl,
        active)
    matcher.add_handler(
        Template(["compute", "integer", TL_ALIASES]),
        set_integer_tl,
        active)
コード例 #5
0
ファイル: __init__.py プロジェクト: parallel-p/please
def add_aggregate_operations(matcher, active):
    from please.build_all.build_tools import build_all
    from please.cleaner import cleaner
    matcher.add_handler(
        Template(["clean|clear"]),
        cleaner.Cleaner().cleanup,
        active)
    for tpl in [["build", "all"], ["build"]]:
        matcher.add_handler(
            Template(tpl),
            build_all,
            active)
コード例 #6
0
def add_import_opertions(matcher, active):
    from please.import_from_polygon import create_contest
    from please.import_from_polygon import create_problem
    from please.import_from_polygon import import_problem_from_polygon
    matcher.add_handler(Template(["import", "polygon", "contest", "#name"]),
                        create_contest, active)
    matcher.add_handler(
        Template([
            "import", "polygon", "problem", "#problem_letter", "from",
            "contest", "#contest_id"
        ]), import_problem_from_polygon, active)
    matcher.add_handler(Template(["import", "polygon", "package", "#package"]),
                        create_problem, active)
コード例 #7
0
ファイル: easter_eggs.py プロジェクト: parallel-p/please
def add_easter_eggs_operations(matcher):
    matcher.add_handler(Template("take over the world".split()),
                        take_over_the_world, True)
    matcher.add_handler(Template("say @words".split()),
                        lambda words: print(" ".join(words)), True)
    matcher.add_handler(
        Template("make me @food".split()),
        lambda food: print("Try: sudo make me " + " ".join(food)), True)
    matcher.add_handler(Template(["sudo", "make", "me", "@food"]),
                        sudo_make_me_food, True)
    matcher.add_handler(Template(["smile"]),
                        lambda: print(random.choice([":-)", "(^ ^)", ":-D"])),
                        True)
コード例 #8
0
def add_generate_operations(matcher, active):
    from please.command_line.generate_tests import generate_tests, generate_tests_with_tags
    from please.latex import latex_tools
    from please.answers_generator.answers_generator import AnswersGenerator
    matcher.add_handler(
        Template(["generate|gen", "tests", "with", "tag|tags", "@tags"]),
        generate_tests_with_tags, active)
    matcher.add_handler(Template(["generate|gen", "tests"]), generate_tests,
                        active)
    matcher.add_handler(Template(["generate|gen", "statement|pdf"]),
                        latex_tools.generate_problem, active)
    matcher.add_handler(Template(["generate|gen", "answers|ans"]),
                        AnswersGenerator.generate, active)
コード例 #9
0
def add_export_operations(matcher):
    from please.exporter.exporter import export
    matcher.add_handler(
        Template([
            "export", "to", "#server_name", "contest", "#contest_id",
            "problem|problems", "@problems"
        ]), export, True)
コード例 #10
0
ファイル: please_test.py プロジェクト: parallel-p/please
 def setUp(self):
     self.ifed()
     self.__matcher = Matcher()
     self.__matcher.startdir = '.'
     self.__matcher.add_handler(
         Template(["create", "problem", "#shortname"]),
         problem_gen.generate_problem, True)
     self.__matcher.matches("create problem problem_test".split())
コード例 #11
0
ファイル: solutions.py プロジェクト: parallel-p/please
def add_checking_solution_operations(matcher, active):
    from please.solution_tester import check_solution
    for tpl in [["run|check", "solutions|sols|all"],
                "check|run all solutions|sols".split()]:
        matcher.add_handler(Template(tpl), check_solution.check_all_solutions,
                            active)

    #TODO:support checking several but not all solutions

    #TODO:support "check #path" in current implementation it is
    #conflict with "check main|all|sols|solutions"
    for tpl in [["check|run", "solution|sol|solutions|sols", "#substr"]]:
        matcher.add_handler(Template(tpl), check_solution.check_solution,
                            active)

    for tpl in [["check|run", "main", "solution|sol"], ["check", "main"]]:
        matcher.add_handler(Template(tpl), check_solution.check_main_solution,
                            active)
コード例 #12
0
ファイル: please_test.py プロジェクト: parallel-p/please
    def test_help(self):
        """ Checks command 'help' """

        open_config = package_config.PackageConfig.get_config('.')
        in_problem_folder = (package_config != False)
        globalconfig.in_problem_folder = in_problem_folder

        self.__matcher.add_handler(Template(["help"]), print_help, True)
        self.__matcher.matches("help".split())
コード例 #13
0
def add_stress_test_operations(matcher, active):
    from please import stress_tester
    from please.package import package_config
    pkg = package_config.PackageConfig.get_config()
    stresser = stress_tester.StressTester(config=pkg)
    matcher.add_handler(Template(["stress", "$solution", "$generator"]),
                        stresser, active)
    matcher.add_handler(
        Template(["stress", "$solution", "$correct_solution", "$generator"]),
        stresser, active)
    matcher.add_handler(
        Template(
            ["stress", "$solution", "$generator", "with", "arg|args",
             "@args"]), stresser, active)
    matcher.add_handler(
        Template([
            "stress", "$solution", "$correct_solution", "$generator", "with",
            "arg|args", "@args"
        ]), stresser, active)
コード例 #14
0
ファイル: please_test.py プロジェクト: parallel-p/please
    def test_add_tags(self):
        """ Checks command 'add tags tag1 tag2 ... tagN' """

        start_dir = os.getcwd()
        os.chdir("problem_test")
        #package_config.PackageConfig.configs_dict = {}
        self.__matcher.add_handler(Template(["add", "tag|tags", "@tags"]),
                                   add_tags, True)
        self.__matcher.matches("add tags tag1 tag2 tag3 tag4".split())

        open_config = package_config.PackageConfig.get_config(
            ignore_cache=True)

        os.chdir(start_dir)

        self.assertEqual(open_config["tags"], ["tag1", "tag2", "tag3", "tag4"])
コード例 #15
0
ファイル: please_test.py プロジェクト: parallel-p/please
    def test_add_standard_checker(self):
        """ Checks command 'add standard checker checker_name' """
        start_dir = os.getcwd()
        os.chdir("problem_test")

        open_config = package_config.PackageConfig.get_config()
        self.__matcher.add_handler(
            Template(["add", "standard", "checker", "#checker"]),
            add_standard_checker_to_solution, True)
        self.__matcher.matches("add standard checker wcmp".split())
        os.remove("wcmp.cpp")

        os.chdir(start_dir)
        self.assertEqual(
            os.path.join(start_dir, "please", "checkers", "wcmp.cpp"),
            open_config["checker"])
コード例 #16
0
ファイル: please_test.py プロジェクト: parallel-p/please
    def test_generate_statement(self):
        """ Checks command 'generate statement' """

        start_dir = os.getcwd()
        #shutil.copy(os.path.join("island", "statements", "default.ru.pdf"), ".")
        test_problem_dir = os.path.join("test_problems", "island")
        os.chdir(test_problem_dir)
        if os.path.exists(os.path.join("statements", "default.ru.pdf")):
            os.remove(os.path.join("statements", "default.ru.pdf"))

        self.__matcher.add_handler(Template(["generate", "statement"]),
                                   latex_tools.generate_problem, True)
        self.__matcher.matches("generate statement".split())

        os.chdir(start_dir)
        self.assertTrue(
            os.path.exists(
                os.path.join(test_problem_dir, "statements",
                             "default.ru.pdf")))
コード例 #17
0
ファイル: solutions.py プロジェクト: parallel-p/please
def add_solution_modifications(matcher, active):
    from please.add_source.add_source import del_props, del_solution,\
                                             add_solution, add_main_solution,\
                                             change_solution
    matcher.add_handler(Template(["set", "main", "solution", "$path"]),
                        add_main_solution, active)
    matcher.add_handler(Template(["add", "solution|sol", "$path"]),
                        add_solution, active)
    matcher.add_handler(Template(["add", "solution|sol", "$path", "@args"]),
                        add_solution, active)
    matcher.add_handler(Template(["delete|del", "solution|sol", "#path"]),
                        del_solution, active)
    matcher.add_handler(Template(["change", "prop|properties", "@args"]),
                        change_solution, active)
    matcher.add_handler(Template(["delete|del", "prop|properties", "@args"]),
                        del_props, active)
コード例 #18
0
ファイル: template_test.py プロジェクト: parallel-p/please
 def __tests_runner(self,template,args,right_ans):
         self.assertEqual(
                 Template(template.split()).corresponds('.', args.split()),
                 right_ans)
コード例 #19
0
ファイル: help.py プロジェクト: parallel-p/please
def add_help_commands(matcher):
    from please.command_line.commands import print_help, print_lite_help
    matcher.add_handler(Template(["help"]), print_help, True)
    matcher.add_handler(Template(["commands"]), print_lite_help, True)
コード例 #20
0
ファイル: help.py プロジェクト: parallel-p/please
def add_todo_operations(matcher, active):
    from please.todo import todo_generator
    for tpl in [["show", "todo"], ["todo"]]:
        matcher.add_handler(Template(tpl),
                            todo_generator.TodoGenerator.get_todo, active)