Skip to content

Commit

Permalink
Use the new utils in the cmdline and fix all other warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
haz committed Dec 23, 2022
1 parent f1407cf commit 0c63e38
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
8 changes: 3 additions & 5 deletions pddl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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__":
Expand Down
24 changes: 18 additions & 6 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
),
],
)
Expand All @@ -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):
Expand Down

0 comments on commit 0c63e38

Please sign in to comment.