diff --git a/pddl/__main__.py b/pddl/__main__.py index 2269d53..6d1fb01 100644 --- a/pddl/__main__.py +++ b/pddl/__main__.py @@ -14,13 +14,11 @@ """Main entrypoint for the PDDL parser CLI tool.""" import os import sys -from pathlib import Path import click +from pddl import parse_domain, parse_problem from pddl.formatter import domain_to_string, problem_to_string -from pddl.parser.domain import DomainParser -from pddl.parser.problem import ProblemParser @click.group() @@ -38,7 +36,7 @@ def domain(domain_file, quiet): """Check a PDDL domain file is correct.""" if quiet: sys.stdout = open(os.devnull, "a") - print(domain_to_string(DomainParser()(Path(domain_file).read_text()))) + print(domain_to_string(parse_domain(domain_file))) @cli.command() @@ -48,7 +46,7 @@ def problem(problem_file, quiet): """Check a PDDL problem file is correct.""" if quiet: sys.stdout = open(os.devnull, "a") - print(problem_to_string(ProblemParser()(Path(problem_file).read_text()))) + print(problem_to_string(parse_problem(problem_file))) if __name__ == "__main__": diff --git a/tests/test_parser.py b/tests/test_parser.py index 2ae9056..d7af5b3 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -15,7 +15,7 @@ from pathlib import Path import pytest -from pytest import lazy_fixture # type: ignore # noqa +from pytest import lazy_fixture # type:ignore # noqa from pddl.core import Domain, Problem from tests.conftest import ( @@ -42,11 +42,17 @@ def test_problem_parser(problem_parser, pddl_file: Path): @pytest.mark.parametrize( "pddl_file,expected_domain", [ - (BLOCKSWORLD_FILES / "domain.pddl", lazy_fixture("blocksworld_domain")), - (TRIANGLE_FILES / "domain.pddl", lazy_fixture("triangle_tireworld_domain")), + ( + BLOCKSWORLD_FILES / "domain.pddl", + lazy_fixture("blocksworld_domain"), # type:ignore + ), + ( + TRIANGLE_FILES / "domain.pddl", + lazy_fixture("triangle_tireworld_domain"), # type:ignore + ), ( BLOCKSWORLD_FOND_FILES / "domain.pddl", - lazy_fixture("blocksworld_fond_domain"), + lazy_fixture("blocksworld_fond_domain"), # type:ignore ), ], ) @@ -61,8 +67,14 @@ def test_check_domain_parser_output(domain_parser, pddl_file: Path, expected_dom @pytest.mark.parametrize( "pddl_file,expected_problem", [ - (BLOCKSWORLD_FILES / "p01.pddl", lazy_fixture("blocksworld_problem_01")), - (BLOCKSWORLD_FOND_FILES / "p01.pddl", lazy_fixture("blocksworld_fond_01")), + ( + BLOCKSWORLD_FILES / "p01.pddl", + lazy_fixture("blocksworld_problem_01"), # type:ignore + ), + ( + BLOCKSWORLD_FOND_FILES / "p01.pddl", + lazy_fixture("blocksworld_fond_01"), # type:ignore + ), ], ) def test_check_problem_parser_output(problem_parser, pddl_file: Path, expected_problem):