plain-parser 0.1.5.dev18__tar.gz → 0.1.5.dev19__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plain_parser-0.1.5.dev19/PKG-INFO +145 -0
- plain_parser-0.1.5.dev19/README.md +122 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/src/plain_parser/__init__.py +3 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/src/plain_parser/cli.py +107 -37
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/src/plain_parser/concept_utils.py +0 -9
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/src/plain_parser/exceptions.py +6 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/src/plain_parser/plain_file.py +225 -267
- plain_parser-0.1.5.dev19/src/plain_parser/plain_spec.py +283 -0
- plain_parser-0.1.5.dev19/src/plain_parser/project.py +160 -0
- plain_parser-0.1.5.dev19/src/plain_parser/test_plain_file.py +247 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/base64_resource.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/binary_resource.plain +2 -1
- plain_parser-0.1.5.dev19/tests/data/cli/code_variable_conflict.plain +11 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/missing_resource.plain +2 -1
- plain_parser-0.1.5.dev19/tests/data/cli/parent_link/a/spec/top.plain +8 -0
- plain_parser-0.1.5.dev19/tests/data/cli/project/config.yaml +3 -0
- plain_parser-0.1.5.dev19/tests/data/cli/project/tests/todo/add-task.plain +17 -0
- plain_parser-0.1.5.dev19/tests/data/cli/project/tests/todo/list-tasks.plain +11 -0
- plain_parser-0.1.5.dev19/tests/data/cli/project/todo.plain +15 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/requires_binary_resource_base.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/requires_binary_resource_top.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/resource_before_frid_walk/base.plain +2 -1
- plain_parser-0.1.5.dev19/tests/data/cli/resource_before_frid_walk/top.plain +16 -0
- plain_parser-0.1.5.dev19/tests/data/cli/shared_link_helper.plain +8 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/shared_link_top.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/subdir/nested.plain +2 -1
- plain_parser-0.1.5.dev19/tests/data/cli/template_link/spec/top.plain +8 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/undefined_concept.plain +4 -2
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/valid.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/imports/circular_imports_main.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/imports/diamond_imports_main.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/imports/import_with_functionalities.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/imports/imports_module_with_functionalities.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/imports/non_existent_import.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfile/missing_non_functional_requirements.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfile/plain_source_with_absolute_link.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfile/plain_source_with_missing_link.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfile/plain_source_with_url_link.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfile/task_manager_with_reference_links.plain +12 -6
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfile/without_non_functional_requirement.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/concept_validation_defined_nondefined.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/concept_validation_defined_nondefined_2.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/concept_validation_definition.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/concept_validation_noconcepts.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/concept_validation_nonconcept.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/concept_validation_nondefined.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/concept_validation_redefinition.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/concept_validation_several_concepts.plain +6 -3
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/concept_validation_valid.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/cyclic_definitions.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/cyclic_definitions_across_import.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/cyclic_definitions_long.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/cyclic_definitions_sub_bullet.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_defaults_exported.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_example.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_imported_exported.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_inherited_reexported.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_malformed.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_missing_definition.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_missing_definition_example.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_multiple_per_bullet.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_multiple_per_bullet_undefined.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_nested.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_nested_example.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_no_definitions.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_not_declared.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_not_declared_example.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_transitive_example.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_transitive_l1.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_transitive_l2.plain +2 -1
- plain_parser-0.1.5.dev19/tests/data/plainfileparser/func_id_duplicate.plain +14 -0
- plain_parser-0.1.5.dev19/tests/data/plainfileparser/func_id_invalid.plain +11 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/plain_file_parser_with_comments.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/plain_file_with_comments_indented.plain +2 -1
- plain_parser-0.1.5.dev19/tests/data/plainfileparser/regular_plain_source.plain +12 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/required_concepts_example.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/required_concepts_missing.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/required_concepts_module.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/required_concepts_partial.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/required_concepts_partial_duplicate.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/requires_without_definitions_example.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/topological_sort.plain +6 -3
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/topological_sort_not_referenced.plain +8 -4
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/chain_base.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/chain_fork_top.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/chain_middle.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/chain_top.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/circular_requires_main.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/circular_requires_sub.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/diamond_requires_1.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/diamond_requires_2.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/diamond_requires_common.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/diamond_requires_main.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/independent_requires_1.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/independent_requires_2.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/independent_requires_main.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/invalid_ancestor_base.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/invalid_ancestor_top.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/non_existent_require.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/normal_requires_1.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/normal_requires_2.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/normal_requires_common.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/normal_requires_main.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/shared_export_above.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/shared_export_base.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/shared_export_middle.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/requires/shared_export_top.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/simple.plain +2 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/templates/block_level_include.plain +2 -3
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/templates/code_variables.plain +2 -1
- plain_parser-0.1.5.dev19/tests/data/templates/implement.plain +3 -0
- plain_parser-0.1.5.dev19/tests/data/templates/implement_2.plain +3 -0
- plain_parser-0.1.5.dev19/tests/data/templates/malformed_tag.plain +5 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/templates/template_include.plain +2 -1
- plain_parser-0.1.5.dev19/tests/data/templates/unterminated_output.plain +4 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/comment_only_conformance.plain +10 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/content_before_scenario.plain +13 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/content_before_section.plain +10 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/duplicate_scenario_id.plain +14 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/duplicate_section.plain +13 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/empty_scenario.plain +14 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/empty_sections.plain +8 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/extra_frontmatter_key.plain +9 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/invalid_scenario_id.plain +11 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/link_to_plain_file.plain +11 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/minimal.plain +6 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/missing_acceptance_section.plain +9 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/missing_func_id.plain +7 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/missing_link.plain +11 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/module_not_a_string.plain +8 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/notes.md +1 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/scenario_before_section.plain +11 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/sections_out_of_order.plain +11 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/unknown_section.plain +11 -0
- plain_parser-0.1.5.dev19/tests/data/testplainfile/valid.plain +40 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/test_cli.py +227 -23
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/test_imports.py +9 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/test_loaders.py +1 -1
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/test_plainfileparser.py +213 -90
- plain_parser-0.1.5.dev19/tests/test_plainspec.py +232 -0
- plain_parser-0.1.5.dev19/tests/test_project.py +311 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/test_requires.py +2 -2
- plain_parser-0.1.5.dev19/tests/test_test_plain_file.py +283 -0
- plain_parser-0.1.5.dev18/PKG-INFO +0 -125
- plain_parser-0.1.5.dev18/README.md +0 -102
- plain_parser-0.1.5.dev18/src/plain_parser/plain_spec.py +0 -414
- plain_parser-0.1.5.dev18/tests/data/cli/acceptance_test_binary_resource.plain +0 -10
- plain_parser-0.1.5.dev18/tests/data/cli/acceptance_test_resource.plain +0 -10
- plain_parser-0.1.5.dev18/tests/data/cli/code_variable_conflict.plain +0 -9
- plain_parser-0.1.5.dev18/tests/data/cli/parent_link/a/spec/top.plain +0 -7
- plain_parser-0.1.5.dev18/tests/data/cli/resource_before_frid_walk/top.plain +0 -14
- plain_parser-0.1.5.dev18/tests/data/cli/shared_link_helper.plain +0 -7
- plain_parser-0.1.5.dev18/tests/data/cli/template_link/spec/top.plain +0 -7
- plain_parser-0.1.5.dev18/tests/data/plainfileparser/concept_validation_acceptance_tests.plain +0 -20
- plain_parser-0.1.5.dev18/tests/data/plainfileparser/concept_validation_acceptance_tests_nondefined.plain +0 -20
- plain_parser-0.1.5.dev18/tests/data/templates/implement.plain +0 -3
- plain_parser-0.1.5.dev18/tests/data/templates/implement_2.plain +0 -3
- plain_parser-0.1.5.dev18/tests/data/templates/malformed_tag.plain +0 -4
- plain_parser-0.1.5.dev18/tests/data/templates/unterminated_output.plain +0 -3
- plain_parser-0.1.5.dev18/tests/test_plainfile.py +0 -270
- plain_parser-0.1.5.dev18/tests/test_plainspec.py +0 -133
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/.flake8 +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/.github/dependabot.yml +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/.github/workflows/lint-and-test.yml +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/.github/workflows/notify-slack-on-main-merge.yml +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/.github/workflows/publish-dev-to-pypi.yml +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/.github/workflows/publish-to-pypi.yml +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/.gitignore +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/LICENSE +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/pyproject.toml +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/src/plain_parser/graph.py +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/src/plain_parser/liquid_nodes.py +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/src/plain_parser/loaders.py +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/__init__.py +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/conftest.py +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/binary.bin +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/code_variable_template.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/not_plain.md +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/notes.md +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/parent_link/b/shared/notes.md +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/parent_link/b/tpl/.gitkeep +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/resource_before_frid_walk/snippet.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/cli/template_link/tpl/notes.md +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/imports/circular_imports_1.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/imports/circular_imports_2.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/imports/diamond_import_1.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/imports/diamond_import_2.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/imports/diamond_import_common.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfile/add_new_task_modal_specification.yaml +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfile/duplicate_specification_heading.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfile/empty_functional_specs_section.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfile/invalid_specification_order.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfile/no_functional_specs_section.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfile/task_list_ui_specification.yaml +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/exported_concepts_base.plain +0 -0
- /plain_parser-0.1.5.dev18/tests/data/plainfileparser/regular_plain_source.plain → /plain_parser-0.1.5.dev19/tests/data/plainfileparser/old_syntax_functional_specs.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/required_concepts.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/required_concepts_defs.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/required_concepts_l1.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/plainfileparser/required_concepts_l2.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/sample_base64_image.txt +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/templates/header.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/data/templates/test_hardest_problem.plain +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/test_concept_utils.py +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/test_exceptions.py +0 -0
- {plain_parser-0.1.5.dev18 → plain_parser-0.1.5.dev19}/tests/test_graph.py +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: plain-parser
|
|
3
|
+
Version: 0.1.5.dev19
|
|
4
|
+
Summary: Parser for ***plain specification files
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Classifier: Intended Audience :: Developers
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Requires-Dist: mistletoe<2,>=1.6.0
|
|
13
|
+
Requires-Dist: python-frontmatter<2,>=1.3.0
|
|
14
|
+
Requires-Dist: python-liquid2<0.5,>=0.4.0
|
|
15
|
+
Requires-Dist: pyyaml<7,>=6
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: black==26.10.1; extra == 'dev'
|
|
18
|
+
Requires-Dist: flake8==7.4.1; extra == 'dev'
|
|
19
|
+
Requires-Dist: isort==9.0.2; extra == 'dev'
|
|
20
|
+
Requires-Dist: mypy==2.4.0; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest==9.1.1; extra == 'dev'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# plain-parser
|
|
25
|
+
|
|
26
|
+
Python parser for [`***plain`](https://www.plainlang.org/docs/) specification files.
|
|
27
|
+
|
|
28
|
+
Reads a `.plain` module with its `import` / `requires` chain and its test plain files, resolves Liquid templates,
|
|
29
|
+
validates concepts and linked resources, and returns the marshalled specification tree of every module in the
|
|
30
|
+
chain, with the test scenarios of each functionality merged in.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install plain-parser
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Command line
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
plain-parser check <file.plain> [--template-dir DIR] [--tests-folder DIR]... [--config-name NAME]
|
|
42
|
+
plain-parser parse <file.plain> [--template-dir DIR] [--tests-folder DIR]... [--config-name NAME]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Both commands parse the module and its `requires` chain, bind the test plain files under the tests folders to the
|
|
46
|
+
functionalities, check that every linked resource is an existing file (not a directory), and walk the module's
|
|
47
|
+
functionalities. They stop at the first error.
|
|
48
|
+
|
|
49
|
+
### `check`
|
|
50
|
+
|
|
51
|
+
Validates the module. In addition to the steps above it reads every linked file and rejects binary files and
|
|
52
|
+
files holding a large base64 blob. When the config file names a `conformance-tests-script`, every functionality
|
|
53
|
+
of every module in the chain needs a test plain file bound to it; the sections of the file may be empty.
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
$ plain-parser check my_spec.plain
|
|
57
|
+
my_spec.plain: OK
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Exit `0` when the module is valid. On an error, `Error: …` is written to stderr and the exit code is `1`. The
|
|
61
|
+
message names the file and the line where known. The previous syntax (`- ` bullets instead of `# <func-id>`
|
|
62
|
+
headings in `***functional specs***`, an `***acceptance tests***` section in a spec plain file) is reported as not
|
|
63
|
+
supported. A functionality without a test plain file names the `add-test-scenarios` skill.
|
|
64
|
+
|
|
65
|
+
### `parse`
|
|
66
|
+
|
|
67
|
+
Prints the parse result as one UTF-8 JSON document on stdout. Linked files are located but not read.
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
$ plain-parser parse my_spec.plain
|
|
71
|
+
{
|
|
72
|
+
"format_version": 2,
|
|
73
|
+
"modules": [{"module": "...", "tree": {...}}, ...],
|
|
74
|
+
"resources": {...},
|
|
75
|
+
"test_plain_files": {...}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- `format_version`: `2`.
|
|
80
|
+
- `modules`: every module in the `requires` chain, in build order: deepest ancestor first, the module itself last.
|
|
81
|
+
Each entry has the module name and its specification tree, in the shape described under *Python* below.
|
|
82
|
+
- `resources`: every linked-resource target in the chain and its test plain files, as written in the spec, mapped
|
|
83
|
+
to the path it resolves to, relative to the entry module's directory, with `/` as separator: `notes.md` when
|
|
84
|
+
found next to the module, `../tpl/notes.md` when found in a template directory. The directory part is lexical
|
|
85
|
+
(symlinks not resolved) and the target is appended as written (`..` kept), so joining the value onto the entry
|
|
86
|
+
module's directory names the file the parser matched. When no relative path exists (another drive on Windows)
|
|
87
|
+
the value is the absolute path, still with `/`. Two spellings of one file (`notes.md`, `./notes.md`) are two
|
|
88
|
+
keys.
|
|
89
|
+
- `test_plain_files`: every test plain file read, by its path relative to the entry module's directory with `/`
|
|
90
|
+
as separator, mapped to `{"module": ..., "func_id": ...}`, the functionality it binds to.
|
|
91
|
+
|
|
92
|
+
Exit `0` on success. On a parser error the JSON is `{"format_version": 2, "type": "<error class>",
|
|
93
|
+
"message": "…"}` and the exit code is `1`.
|
|
94
|
+
|
|
95
|
+
### Options and exit codes
|
|
96
|
+
|
|
97
|
+
Modules and `{% include %}` templates are looked up in the `.plain` file's directory, then in `--template-dir`.
|
|
98
|
+
When `--template-dir` is not given, it is read from the `template-dir` key of `config.yaml` (or the file named by
|
|
99
|
+
`--config-name`), found next to the `.plain` file or in the working directory. Finding it in both is a usage
|
|
100
|
+
error. The config file is read even when `--template-dir` is given, so a malformed one fails the run either way.
|
|
101
|
+
|
|
102
|
+
Test plain files are the `.plain` files under the tests folders: those given with `--tests-folder` (repeat the
|
|
103
|
+
option for more than one), else the `tests-folder` key of the config file (a string or a list). Without both, no test
|
|
104
|
+
plain files are read, and a config file that names a `conformance-tests-script` makes that a usage error. A test
|
|
105
|
+
directory that does not exist is skipped. Linked resources in a scenario are looked up
|
|
106
|
+
as in a module. The `conformance-tests-script` key of the config file turns on the check that every
|
|
107
|
+
functionality has a test plain file. Other config keys are ignored.
|
|
108
|
+
|
|
109
|
+
| Exit code | Meaning |
|
|
110
|
+
|---|---|
|
|
111
|
+
| `0` | Success |
|
|
112
|
+
| `1` | The module, its chain, a test plain file, or a linked resource is invalid |
|
|
113
|
+
| `2` | Usage error, including an ambiguous or malformed config file |
|
|
114
|
+
| `130` | Interrupted |
|
|
115
|
+
|
|
116
|
+
## Python
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from plain_parser import plain_file_parser, project
|
|
120
|
+
|
|
121
|
+
module_name, plain_source_tree, required_modules = plain_file_parser("my_spec.plain", ["."])
|
|
122
|
+
|
|
123
|
+
result = project.parse_project("my_spec.plain", ["."], ["tests"], require_test_plain_files=True)
|
|
124
|
+
chain = result.chain # (module name, plain source tree) pairs, deepest ancestor first, the module itself last
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`plain_source_tree` is a dict keyed by section. `definitions`, `implementation reqs` and `test reqs` are lists
|
|
128
|
+
of `{"markdown": ..., "linked_resources": [...]}` entries. `functional specs` is a list of
|
|
129
|
+
`{"id", "markdown", "linked_resources", "conformance_tests", "acceptance_tests"}` entries, one per `# <func-id>`
|
|
130
|
+
heading in file order; each test entry is `{"id", "text", "linked_resources"}` with the scenario text as written.
|
|
131
|
+
`plain_parser.plain_spec` has helpers for walking functionalities by func-id (`get_frids`,
|
|
132
|
+
`get_specifications_for_frid`, `collect_linked_resources`).
|
|
133
|
+
|
|
134
|
+
## Development
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
uv venv --python 3.11 && source .venv/bin/activate
|
|
138
|
+
uv pip install -e ".[dev]"
|
|
139
|
+
pytest
|
|
140
|
+
black . --check && isort . --check-only && flake8 . && mypy src
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
MIT, see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# plain-parser
|
|
2
|
+
|
|
3
|
+
Python parser for [`***plain`](https://www.plainlang.org/docs/) specification files.
|
|
4
|
+
|
|
5
|
+
Reads a `.plain` module with its `import` / `requires` chain and its test plain files, resolves Liquid templates,
|
|
6
|
+
validates concepts and linked resources, and returns the marshalled specification tree of every module in the
|
|
7
|
+
chain, with the test scenarios of each functionality merged in.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install plain-parser
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Command line
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
plain-parser check <file.plain> [--template-dir DIR] [--tests-folder DIR]... [--config-name NAME]
|
|
19
|
+
plain-parser parse <file.plain> [--template-dir DIR] [--tests-folder DIR]... [--config-name NAME]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Both commands parse the module and its `requires` chain, bind the test plain files under the tests folders to the
|
|
23
|
+
functionalities, check that every linked resource is an existing file (not a directory), and walk the module's
|
|
24
|
+
functionalities. They stop at the first error.
|
|
25
|
+
|
|
26
|
+
### `check`
|
|
27
|
+
|
|
28
|
+
Validates the module. In addition to the steps above it reads every linked file and rejects binary files and
|
|
29
|
+
files holding a large base64 blob. When the config file names a `conformance-tests-script`, every functionality
|
|
30
|
+
of every module in the chain needs a test plain file bound to it; the sections of the file may be empty.
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
$ plain-parser check my_spec.plain
|
|
34
|
+
my_spec.plain: OK
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Exit `0` when the module is valid. On an error, `Error: …` is written to stderr and the exit code is `1`. The
|
|
38
|
+
message names the file and the line where known. The previous syntax (`- ` bullets instead of `# <func-id>`
|
|
39
|
+
headings in `***functional specs***`, an `***acceptance tests***` section in a spec plain file) is reported as not
|
|
40
|
+
supported. A functionality without a test plain file names the `add-test-scenarios` skill.
|
|
41
|
+
|
|
42
|
+
### `parse`
|
|
43
|
+
|
|
44
|
+
Prints the parse result as one UTF-8 JSON document on stdout. Linked files are located but not read.
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
$ plain-parser parse my_spec.plain
|
|
48
|
+
{
|
|
49
|
+
"format_version": 2,
|
|
50
|
+
"modules": [{"module": "...", "tree": {...}}, ...],
|
|
51
|
+
"resources": {...},
|
|
52
|
+
"test_plain_files": {...}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- `format_version`: `2`.
|
|
57
|
+
- `modules`: every module in the `requires` chain, in build order: deepest ancestor first, the module itself last.
|
|
58
|
+
Each entry has the module name and its specification tree, in the shape described under *Python* below.
|
|
59
|
+
- `resources`: every linked-resource target in the chain and its test plain files, as written in the spec, mapped
|
|
60
|
+
to the path it resolves to, relative to the entry module's directory, with `/` as separator: `notes.md` when
|
|
61
|
+
found next to the module, `../tpl/notes.md` when found in a template directory. The directory part is lexical
|
|
62
|
+
(symlinks not resolved) and the target is appended as written (`..` kept), so joining the value onto the entry
|
|
63
|
+
module's directory names the file the parser matched. When no relative path exists (another drive on Windows)
|
|
64
|
+
the value is the absolute path, still with `/`. Two spellings of one file (`notes.md`, `./notes.md`) are two
|
|
65
|
+
keys.
|
|
66
|
+
- `test_plain_files`: every test plain file read, by its path relative to the entry module's directory with `/`
|
|
67
|
+
as separator, mapped to `{"module": ..., "func_id": ...}`, the functionality it binds to.
|
|
68
|
+
|
|
69
|
+
Exit `0` on success. On a parser error the JSON is `{"format_version": 2, "type": "<error class>",
|
|
70
|
+
"message": "…"}` and the exit code is `1`.
|
|
71
|
+
|
|
72
|
+
### Options and exit codes
|
|
73
|
+
|
|
74
|
+
Modules and `{% include %}` templates are looked up in the `.plain` file's directory, then in `--template-dir`.
|
|
75
|
+
When `--template-dir` is not given, it is read from the `template-dir` key of `config.yaml` (or the file named by
|
|
76
|
+
`--config-name`), found next to the `.plain` file or in the working directory. Finding it in both is a usage
|
|
77
|
+
error. The config file is read even when `--template-dir` is given, so a malformed one fails the run either way.
|
|
78
|
+
|
|
79
|
+
Test plain files are the `.plain` files under the tests folders: those given with `--tests-folder` (repeat the
|
|
80
|
+
option for more than one), else the `tests-folder` key of the config file (a string or a list). Without both, no test
|
|
81
|
+
plain files are read, and a config file that names a `conformance-tests-script` makes that a usage error. A test
|
|
82
|
+
directory that does not exist is skipped. Linked resources in a scenario are looked up
|
|
83
|
+
as in a module. The `conformance-tests-script` key of the config file turns on the check that every
|
|
84
|
+
functionality has a test plain file. Other config keys are ignored.
|
|
85
|
+
|
|
86
|
+
| Exit code | Meaning |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `0` | Success |
|
|
89
|
+
| `1` | The module, its chain, a test plain file, or a linked resource is invalid |
|
|
90
|
+
| `2` | Usage error, including an ambiguous or malformed config file |
|
|
91
|
+
| `130` | Interrupted |
|
|
92
|
+
|
|
93
|
+
## Python
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from plain_parser import plain_file_parser, project
|
|
97
|
+
|
|
98
|
+
module_name, plain_source_tree, required_modules = plain_file_parser("my_spec.plain", ["."])
|
|
99
|
+
|
|
100
|
+
result = project.parse_project("my_spec.plain", ["."], ["tests"], require_test_plain_files=True)
|
|
101
|
+
chain = result.chain # (module name, plain source tree) pairs, deepest ancestor first, the module itself last
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`plain_source_tree` is a dict keyed by section. `definitions`, `implementation reqs` and `test reqs` are lists
|
|
105
|
+
of `{"markdown": ..., "linked_resources": [...]}` entries. `functional specs` is a list of
|
|
106
|
+
`{"id", "markdown", "linked_resources", "conformance_tests", "acceptance_tests"}` entries, one per `# <func-id>`
|
|
107
|
+
heading in file order; each test entry is `{"id", "text", "linked_resources"}` with the scenario text as written.
|
|
108
|
+
`plain_parser.plain_spec` has helpers for walking functionalities by func-id (`get_frids`,
|
|
109
|
+
`get_specifications_for_frid`, `collect_linked_resources`).
|
|
110
|
+
|
|
111
|
+
## Development
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
uv venv --python 3.11 && source .venv/bin/activate
|
|
115
|
+
uv pip install -e ".[dev]"
|
|
116
|
+
pytest
|
|
117
|
+
black . --check && isort . --check-only && flake8 . && mypy src
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT, see [LICENSE](LICENSE).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Parser for ***plain specification files."""
|
|
2
2
|
|
|
3
|
-
from plain_parser import concept_utils, exceptions, loaders, plain_file, plain_spec
|
|
3
|
+
from plain_parser import concept_utils, exceptions, loaders, plain_file, plain_spec, project, test_plain_file
|
|
4
4
|
from plain_parser.plain_file import (
|
|
5
5
|
PlainFileParseResult,
|
|
6
6
|
get_filename_from_module_name,
|
|
@@ -26,4 +26,6 @@ __all__ = [
|
|
|
26
26
|
"plain_file",
|
|
27
27
|
"plain_file_parser",
|
|
28
28
|
"plain_spec",
|
|
29
|
+
"project",
|
|
30
|
+
"test_plain_file",
|
|
29
31
|
]
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
"""Command-line entry point: ``plain-parser {check,parse} <file.plain> [--template-dir DIR] [--
|
|
1
|
+
"""Command-line entry point: ``plain-parser {check,parse} <file.plain> [--template-dir DIR] [--tests-folder DIR]...
|
|
2
|
+
[--config-name NAME]``."""
|
|
2
3
|
|
|
3
4
|
import argparse
|
|
4
5
|
import json
|
|
5
6
|
import os
|
|
6
7
|
import sys
|
|
7
|
-
from dataclasses import dataclass
|
|
8
|
+
from dataclasses import dataclass, field
|
|
8
9
|
|
|
9
10
|
import yaml
|
|
10
11
|
|
|
11
|
-
from plain_parser import loaders,
|
|
12
|
+
from plain_parser import loaders, plain_spec, project
|
|
12
13
|
|
|
13
14
|
DEFAULT_CONFIG_NAME = "config.yaml"
|
|
14
15
|
TEMPLATE_DIR_CONFIG_KEYS = ("template_dir", "template-dir")
|
|
15
|
-
|
|
16
|
+
TESTS_FOLDER_CONFIG_KEYS = ("tests_folder", "tests-folder")
|
|
17
|
+
CONFORMANCE_TESTS_SCRIPT_CONFIG_KEYS = ("conformance_tests_script", "conformance-tests-script")
|
|
18
|
+
PARSE_FORMAT_VERSION = 2
|
|
16
19
|
|
|
17
20
|
|
|
18
21
|
class AmbiguousConfigFileError(Exception):
|
|
@@ -25,13 +28,13 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
25
28
|
|
|
26
29
|
check_parser = subparsers.add_parser(
|
|
27
30
|
"check",
|
|
28
|
-
help="Validate a .plain module and its
|
|
31
|
+
help="Validate a .plain module, its requires chain and its test plain files, and read every linked file: "
|
|
29
32
|
"binary files and large base64 blobs are rejected.",
|
|
30
33
|
)
|
|
31
34
|
parse_parser = subparsers.add_parser(
|
|
32
35
|
"parse",
|
|
33
|
-
help="Print the parse result of a .plain module
|
|
34
|
-
"located but never read.",
|
|
36
|
+
help="Print the parse result of a .plain module, its requires chain and its test plain files as JSON. "
|
|
37
|
+
"Linked files are located but never read.",
|
|
35
38
|
)
|
|
36
39
|
for subparser in (check_parser, parse_parser):
|
|
37
40
|
subparser.add_argument("plain_file", help="Path to the .plain module.")
|
|
@@ -40,11 +43,18 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
40
43
|
help="Directory searched for modules and templates after the .plain file's own directory. "
|
|
41
44
|
"Overrides the template-dir value of the config file.",
|
|
42
45
|
)
|
|
46
|
+
subparser.add_argument(
|
|
47
|
+
"--tests-folder",
|
|
48
|
+
action="append",
|
|
49
|
+
metavar="DIR",
|
|
50
|
+
help="Directory scanned for test plain files; repeat the option for more than one. Overrides the "
|
|
51
|
+
"tests-folder value of the config file. Without both, no test plain files are read.",
|
|
52
|
+
)
|
|
43
53
|
subparser.add_argument(
|
|
44
54
|
"--config-name",
|
|
45
55
|
default=DEFAULT_CONFIG_NAME,
|
|
46
|
-
help="Name of the config file to read template-dir
|
|
47
|
-
"and the current working directory. Defaults to %(default)s.",
|
|
56
|
+
help="Name of the config file to read template-dir, tests-folder and conformance-tests-script from. "
|
|
57
|
+
"Looked up in the .plain file's directory and the current working directory. Defaults to %(default)s.",
|
|
48
58
|
)
|
|
49
59
|
return parser
|
|
50
60
|
|
|
@@ -71,17 +81,39 @@ def resolve_config_file(config_name: str, plain_file_path: str) -> str | None:
|
|
|
71
81
|
return None
|
|
72
82
|
|
|
73
83
|
|
|
74
|
-
|
|
75
|
-
|
|
84
|
+
@dataclass
|
|
85
|
+
class Config:
|
|
86
|
+
template_dir: str | None = None
|
|
87
|
+
tests_folders: list[str] | None = None # None when the config does not set tests-folder.
|
|
88
|
+
conformance_tests_enabled: bool = False # Whether the config names a conformance-tests-script.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _config_value(config: dict, keys: tuple[str, ...]):
|
|
92
|
+
"""The first value set under one of the key spellings, or None."""
|
|
93
|
+
return next((config[key] for key in keys if config.get(key)), None)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def read_config(config_file: str) -> Config:
|
|
97
|
+
"""The values plain-parser reads from the config file, paths resolved against the file's directory. Other keys
|
|
98
|
+
are ignored."""
|
|
76
99
|
with open(config_file) as f:
|
|
77
100
|
config = yaml.safe_load(f) or {}
|
|
78
101
|
|
|
79
|
-
|
|
80
|
-
value =
|
|
81
|
-
if value
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
def resolve(value) -> str:
|
|
103
|
+
value = os.path.expanduser(str(value))
|
|
104
|
+
return value if os.path.isabs(value) else os.path.join(os.path.dirname(config_file), value)
|
|
105
|
+
|
|
106
|
+
result = Config()
|
|
107
|
+
template_dir = _config_value(config, TEMPLATE_DIR_CONFIG_KEYS)
|
|
108
|
+
if template_dir:
|
|
109
|
+
result.template_dir = resolve(template_dir)
|
|
110
|
+
tests_folder = _config_value(config, TESTS_FOLDER_CONFIG_KEYS)
|
|
111
|
+
if tests_folder:
|
|
112
|
+
result.tests_folders = [
|
|
113
|
+
resolve(value) for value in (tests_folder if isinstance(tests_folder, list) else [tests_folder])
|
|
114
|
+
]
|
|
115
|
+
result.conformance_tests_enabled = bool(_config_value(config, CONFORMANCE_TESTS_SCRIPT_CONFIG_KEYS))
|
|
116
|
+
return result
|
|
85
117
|
|
|
86
118
|
|
|
87
119
|
@dataclass
|
|
@@ -92,20 +124,36 @@ class ParseResult:
|
|
|
92
124
|
# Each link target in the chain, as written, to the path it resolves to, relative to the entry module's dir
|
|
93
125
|
# with `/` as separator (loaders.relative_resource_path).
|
|
94
126
|
resources: dict[str, str]
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
127
|
+
# Each test plain file, by its path relative to the entry module's dir with `/`, to the functionality it binds to.
|
|
128
|
+
test_plain_files: dict[str, dict] = field(default_factory=dict)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def parse_spec(
|
|
132
|
+
plain_file_path: str,
|
|
133
|
+
template_dir: str | None,
|
|
134
|
+
load_resources: bool,
|
|
135
|
+
tests_folders: list[str] | None = None,
|
|
136
|
+
require_test_plain_files: bool = False,
|
|
137
|
+
) -> ParseResult:
|
|
138
|
+
"""Parse the module, its requires chain and its test plain files, resolve the links, and walk the entry's
|
|
139
|
+
FRIDs; raise on the first error.
|
|
140
|
+
|
|
141
|
+
Without ``tests_folders`` no test plain files are read. With ``require_test_plain_files``, every functionality needs a
|
|
142
|
+
test plain file bound to it. With ``load_resources``, each module's linked files are
|
|
143
|
+
also read and checked (text only, no large base64 blob) right after that module's links are collected, so a
|
|
144
|
+
resource error is reported before a FRID-walk error.
|
|
102
145
|
"""
|
|
103
146
|
# Absolute, so the chain parse and the resource paths below search the same directories.
|
|
104
|
-
|
|
147
|
+
entry_dir = os.path.dirname(os.path.abspath(plain_file_path))
|
|
148
|
+
template_dirs = [entry_dir]
|
|
105
149
|
if template_dir:
|
|
106
150
|
template_dirs.append(os.path.abspath(template_dir))
|
|
151
|
+
tests_folders = [os.path.abspath(tests_folder) for tests_folder in tests_folders or []]
|
|
107
152
|
|
|
108
|
-
|
|
153
|
+
parsed = project.parse_project(
|
|
154
|
+
os.path.basename(plain_file_path), template_dirs, tests_folders, require_test_plain_files
|
|
155
|
+
)
|
|
156
|
+
chain = parsed.chain
|
|
109
157
|
|
|
110
158
|
# The target joined as written onto its template dir (`..` kept, symlinks not resolved), made relative to the
|
|
111
159
|
# entry module's dir so the result does not depend on where the project sits on the machine.
|
|
@@ -124,12 +172,21 @@ def parse_spec(plain_file_path: str, template_dir: str | None, load_resources: b
|
|
|
124
172
|
for frid in plain_spec.get_frids(top_plain_source_tree):
|
|
125
173
|
plain_spec.get_specifications_for_frid(top_plain_source_tree, frid)
|
|
126
174
|
|
|
127
|
-
|
|
175
|
+
test_plain_files = {
|
|
176
|
+
bound.name: {"module": bound.parsed.module, "func_id": bound.parsed.func_id}
|
|
177
|
+
for bound in parsed.test_plain_files
|
|
178
|
+
}
|
|
179
|
+
return ParseResult(chain, resources, test_plain_files)
|
|
128
180
|
|
|
129
181
|
|
|
130
|
-
def check(
|
|
131
|
-
|
|
132
|
-
|
|
182
|
+
def check(
|
|
183
|
+
plain_file_path: str,
|
|
184
|
+
template_dir: str | None,
|
|
185
|
+
tests_folders: list[str] | None = None,
|
|
186
|
+
require_test_plain_files: bool = False,
|
|
187
|
+
) -> None:
|
|
188
|
+
"""Raise if the module, its requires chain, its test plain files, or its linked resources are invalid."""
|
|
189
|
+
parse_spec(plain_file_path, template_dir, True, tests_folders, require_test_plain_files)
|
|
133
190
|
|
|
134
191
|
|
|
135
192
|
def _error_output(type_name: str, message: str) -> dict:
|
|
@@ -146,15 +203,21 @@ def _encode_output(output: dict) -> bytes:
|
|
|
146
203
|
return (json.dumps(output, indent=2, ensure_ascii=False) + "\n").encode("utf-8")
|
|
147
204
|
|
|
148
205
|
|
|
149
|
-
def parse(
|
|
206
|
+
def parse(
|
|
207
|
+
plain_file_path: str,
|
|
208
|
+
template_dir: str | None,
|
|
209
|
+
tests_folders: list[str] | None = None,
|
|
210
|
+
require_test_plain_files: bool = False,
|
|
211
|
+
) -> int:
|
|
150
212
|
"""Print the parse result, or the parser error, as one UTF-8 JSON document on stdout; return the exit code."""
|
|
151
213
|
output: dict
|
|
152
214
|
try:
|
|
153
|
-
result = parse_spec(plain_file_path, template_dir,
|
|
215
|
+
result = parse_spec(plain_file_path, template_dir, False, tests_folders, require_test_plain_files)
|
|
154
216
|
output = {
|
|
155
217
|
"format_version": PARSE_FORMAT_VERSION,
|
|
156
218
|
"modules": [{"module": module_name, "tree": tree} for module_name, tree in result.modules],
|
|
157
219
|
"resources": result.resources,
|
|
220
|
+
"test_plain_files": result.test_plain_files,
|
|
158
221
|
}
|
|
159
222
|
exit_code = 0
|
|
160
223
|
except Exception as e:
|
|
@@ -209,10 +272,17 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
209
272
|
|
|
210
273
|
try:
|
|
211
274
|
# The config file is resolved even when --template-dir is given, so an ambiguous config is always an error.
|
|
212
|
-
|
|
275
|
+
config = _read_config(parser, args)
|
|
276
|
+
template_dir = args.template_dir or config.template_dir
|
|
277
|
+
tests_folders = args.tests_folder or config.tests_folders
|
|
278
|
+
if config.conformance_tests_enabled and not tests_folders:
|
|
279
|
+
parser.error(
|
|
280
|
+
"conformance-tests-script is set in the config file, but no tests folder is given. "
|
|
281
|
+
"Pass --tests-folder or set tests-folder in the config file."
|
|
282
|
+
)
|
|
213
283
|
if args.command == "parse":
|
|
214
|
-
return parse(args.plain_file,
|
|
215
|
-
check(args.plain_file,
|
|
284
|
+
return parse(args.plain_file, template_dir, tests_folders, config.conformance_tests_enabled)
|
|
285
|
+
check(args.plain_file, template_dir, tests_folders, config.conformance_tests_enabled)
|
|
216
286
|
except KeyboardInterrupt:
|
|
217
287
|
return 130
|
|
218
288
|
except Exception as e:
|
|
@@ -223,10 +293,10 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
223
293
|
return 0
|
|
224
294
|
|
|
225
295
|
|
|
226
|
-
def
|
|
296
|
+
def _read_config(parser: argparse.ArgumentParser, args: argparse.Namespace) -> Config:
|
|
227
297
|
try:
|
|
228
298
|
config_file = resolve_config_file(args.config_name, args.plain_file)
|
|
229
|
-
return
|
|
299
|
+
return read_config(config_file) if config_file is not None else Config()
|
|
230
300
|
except AmbiguousConfigFileError as e:
|
|
231
301
|
parser.error(str(e))
|
|
232
302
|
except Exception as e:
|
|
@@ -117,15 +117,6 @@ def validate_concepts(marshalled_plain_source) -> list[str]:
|
|
|
117
117
|
]:
|
|
118
118
|
errors.extend(validate_concepts_in_spec_group(spec_group, marshalled_plain_source, tmp_tree_based_concepts))
|
|
119
119
|
|
|
120
|
-
if plain_spec.FUNCTIONAL_REQUIREMENTS in marshalled_plain_source:
|
|
121
|
-
for func_spec in marshalled_plain_source[plain_spec.FUNCTIONAL_REQUIREMENTS]:
|
|
122
|
-
if "acceptance_tests" not in func_spec:
|
|
123
|
-
continue
|
|
124
|
-
|
|
125
|
-
acceptance_tests = func_spec["acceptance_tests"]
|
|
126
|
-
for spec in acceptance_tests:
|
|
127
|
-
errors.extend(validate_concepts_in_spec(spec, tmp_tree_based_concepts, plain_spec.ACCEPTANCE_TESTS))
|
|
128
|
-
|
|
129
120
|
return errors
|
|
130
121
|
|
|
131
122
|
|