aas-core-codegen 0.0.16__py3-none-any.whl
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.
- aas_core_codegen/__init__.py +6 -0
- aas_core_codegen/__main__.py +8 -0
- aas_core_codegen/common.py +500 -0
- aas_core_codegen/cpp/__init__.py +1 -0
- aas_core_codegen/cpp/aas_common/__init__.py +6 -0
- aas_core_codegen/cpp/aas_common/_generate.py +713 -0
- aas_core_codegen/cpp/common.py +681 -0
- aas_core_codegen/cpp/constants/__init__.py +6 -0
- aas_core_codegen/cpp/constants/_generate.py +568 -0
- aas_core_codegen/cpp/description.py +654 -0
- aas_core_codegen/cpp/enhancing/__init__.py +4 -0
- aas_core_codegen/cpp/enhancing/_generate.py +993 -0
- aas_core_codegen/cpp/iteration/__init__.py +6 -0
- aas_core_codegen/cpp/iteration/_generate.py +2332 -0
- aas_core_codegen/cpp/jsonization/__init__.py +6 -0
- aas_core_codegen/cpp/jsonization/_generate.py +2619 -0
- aas_core_codegen/cpp/main.py +694 -0
- aas_core_codegen/cpp/naming.py +170 -0
- aas_core_codegen/cpp/optionaling.py +557 -0
- aas_core_codegen/cpp/pattern/__init__.py +6 -0
- aas_core_codegen/cpp/pattern/_generate.py +508 -0
- aas_core_codegen/cpp/revm/__init__.py +6 -0
- aas_core_codegen/cpp/revm/_generate.py +1149 -0
- aas_core_codegen/cpp/stringification/__init__.py +5 -0
- aas_core_codegen/cpp/stringification/_generate.py +955 -0
- aas_core_codegen/cpp/structure/__init__.py +7 -0
- aas_core_codegen/cpp/structure/_generate.py +1503 -0
- aas_core_codegen/cpp/transpilation.py +1383 -0
- aas_core_codegen/cpp/unrolling.py +159 -0
- aas_core_codegen/cpp/verification/__init__.py +6 -0
- aas_core_codegen/cpp/verification/_generate.py +3073 -0
- aas_core_codegen/cpp/visitation/__init__.py +6 -0
- aas_core_codegen/cpp/visitation/_generate.py +521 -0
- aas_core_codegen/cpp/wstringification/__init__.py +5 -0
- aas_core_codegen/cpp/wstringification/_generate.py +586 -0
- aas_core_codegen/cpp/xmlization/__init__.py +6 -0
- aas_core_codegen/cpp/xmlization/_generate.py +5373 -0
- aas_core_codegen/cpp/yielding.py +201 -0
- aas_core_codegen/csharp/__init__.py +1 -0
- aas_core_codegen/csharp/common.py +224 -0
- aas_core_codegen/csharp/constants/__init__.py +5 -0
- aas_core_codegen/csharp/constants/_generate.py +409 -0
- aas_core_codegen/csharp/copying/__init__.py +4 -0
- aas_core_codegen/csharp/copying/_generate.py +498 -0
- aas_core_codegen/csharp/description.py +1103 -0
- aas_core_codegen/csharp/enhancing/__init__.py +4 -0
- aas_core_codegen/csharp/enhancing/_generate.py +667 -0
- aas_core_codegen/csharp/jsonization/__init__.py +4 -0
- aas_core_codegen/csharp/jsonization/_generate.py +1630 -0
- aas_core_codegen/csharp/main.py +421 -0
- aas_core_codegen/csharp/naming.py +157 -0
- aas_core_codegen/csharp/reporting/__init__.py +4 -0
- aas_core_codegen/csharp/reporting/_generate.py +266 -0
- aas_core_codegen/csharp/stringification/__init__.py +4 -0
- aas_core_codegen/csharp/stringification/_generate.py +243 -0
- aas_core_codegen/csharp/structure/__init__.py +6 -0
- aas_core_codegen/csharp/structure/_generate.py +1341 -0
- aas_core_codegen/csharp/transpilation.py +990 -0
- aas_core_codegen/csharp/unrolling.py +211 -0
- aas_core_codegen/csharp/verification/__init__.py +6 -0
- aas_core_codegen/csharp/verification/_generate.py +1457 -0
- aas_core_codegen/csharp/visitation/__init__.py +5 -0
- aas_core_codegen/csharp/visitation/_generate.py +579 -0
- aas_core_codegen/csharp/xmlization/__init__.py +4 -0
- aas_core_codegen/csharp/xmlization/_generate.py +1980 -0
- aas_core_codegen/golang/__init__.py +1 -0
- aas_core_codegen/golang/aas_common/__init__.py +4 -0
- aas_core_codegen/golang/aas_common/_generate.py +152 -0
- aas_core_codegen/golang/common.py +303 -0
- aas_core_codegen/golang/constants/__init__.py +5 -0
- aas_core_codegen/golang/constants/_generate.py +339 -0
- aas_core_codegen/golang/description.py +501 -0
- aas_core_codegen/golang/enhancing/__init__.py +4 -0
- aas_core_codegen/golang/enhancing/_generate.py +527 -0
- aas_core_codegen/golang/jsonization/__init__.py +4 -0
- aas_core_codegen/golang/jsonization/_generate.py +1740 -0
- aas_core_codegen/golang/main.py +368 -0
- aas_core_codegen/golang/naming.py +412 -0
- aas_core_codegen/golang/pointering.py +631 -0
- aas_core_codegen/golang/reporting/__init__.py +4 -0
- aas_core_codegen/golang/reporting/_generate.py +218 -0
- aas_core_codegen/golang/stringification/__init__.py +4 -0
- aas_core_codegen/golang/stringification/_generate.py +394 -0
- aas_core_codegen/golang/structure/__init__.py +6 -0
- aas_core_codegen/golang/structure/_generate.py +1493 -0
- aas_core_codegen/golang/transpilation.py +1191 -0
- aas_core_codegen/golang/unrolling.py +159 -0
- aas_core_codegen/golang/verification/__init__.py +6 -0
- aas_core_codegen/golang/verification/_generate.py +1513 -0
- aas_core_codegen/golang/xmlization/__init__.py +4 -0
- aas_core_codegen/golang/xmlization/_generate.py +2507 -0
- aas_core_codegen/infer_for_schema/__init__.py +21 -0
- aas_core_codegen/infer_for_schema/_inline.py +693 -0
- aas_core_codegen/infer_for_schema/_len.py +527 -0
- aas_core_codegen/infer_for_schema/_pattern.py +311 -0
- aas_core_codegen/infer_for_schema/_set.py +394 -0
- aas_core_codegen/infer_for_schema/_stringify.py +201 -0
- aas_core_codegen/infer_for_schema/_types.py +135 -0
- aas_core_codegen/infer_for_schema/match.py +122 -0
- aas_core_codegen/intermediate/__init__.py +78 -0
- aas_core_codegen/intermediate/_hierarchy.py +397 -0
- aas_core_codegen/intermediate/_stringify.py +989 -0
- aas_core_codegen/intermediate/_translate.py +5128 -0
- aas_core_codegen/intermediate/_types.py +2901 -0
- aas_core_codegen/intermediate/construction.py +750 -0
- aas_core_codegen/intermediate/doc.py +344 -0
- aas_core_codegen/intermediate/pattern_verification.py +428 -0
- aas_core_codegen/intermediate/revm.py +985 -0
- aas_core_codegen/intermediate/type_inference.py +2266 -0
- aas_core_codegen/java/__init__.py +1 -0
- aas_core_codegen/java/common.py +197 -0
- aas_core_codegen/java/constants/__init__.py +5 -0
- aas_core_codegen/java/constants/_generate.py +334 -0
- aas_core_codegen/java/copying/__init__.py +4 -0
- aas_core_codegen/java/copying/_generate.py +502 -0
- aas_core_codegen/java/description.py +774 -0
- aas_core_codegen/java/enhancing/__init__.py +4 -0
- aas_core_codegen/java/enhancing/_generate.py +820 -0
- aas_core_codegen/java/generation/__init__.py +5 -0
- aas_core_codegen/java/generation/_generate.py +285 -0
- aas_core_codegen/java/jsonization/__init__.py +4 -0
- aas_core_codegen/java/jsonization/_generate.py +1472 -0
- aas_core_codegen/java/main.py +438 -0
- aas_core_codegen/java/naming.py +187 -0
- aas_core_codegen/java/optional.py +514 -0
- aas_core_codegen/java/reporting/__init__.py +4 -0
- aas_core_codegen/java/reporting/_generate.py +248 -0
- aas_core_codegen/java/stringification/__init__.py +4 -0
- aas_core_codegen/java/stringification/_generate.py +212 -0
- aas_core_codegen/java/structure/__init__.py +6 -0
- aas_core_codegen/java/structure/_generate.py +1767 -0
- aas_core_codegen/java/transpilation.py +1111 -0
- aas_core_codegen/java/verification/__init__.py +6 -0
- aas_core_codegen/java/verification/_generate.py +1536 -0
- aas_core_codegen/java/visitation/__init__.py +5 -0
- aas_core_codegen/java/visitation/_generate.py +689 -0
- aas_core_codegen/java/xmlization/__init__.py +4 -0
- aas_core_codegen/java/xmlization/_generate.py +2274 -0
- aas_core_codegen/jsonld/__init__.py +1 -0
- aas_core_codegen/jsonld/main.py +455 -0
- aas_core_codegen/jsonschema/__init__.py +1 -0
- aas_core_codegen/jsonschema/main.py +982 -0
- aas_core_codegen/main.py +245 -0
- aas_core_codegen/naming.py +133 -0
- aas_core_codegen/opcua/__init__.py +1 -0
- aas_core_codegen/opcua/main.py +1525 -0
- aas_core_codegen/opcua/naming.py +126 -0
- aas_core_codegen/parse/__init__.py +46 -0
- aas_core_codegen/parse/_rules.py +796 -0
- aas_core_codegen/parse/_stringify.py +532 -0
- aas_core_codegen/parse/_translate.py +3940 -0
- aas_core_codegen/parse/_types.py +973 -0
- aas_core_codegen/parse/retree/__init__.py +46 -0
- aas_core_codegen/parse/retree/_fix.py +434 -0
- aas_core_codegen/parse/retree/_parse.py +1143 -0
- aas_core_codegen/parse/retree/_render.py +298 -0
- aas_core_codegen/parse/retree/_stringify.py +199 -0
- aas_core_codegen/parse/retree/_types.py +362 -0
- aas_core_codegen/parse/retree/_visitor.py +70 -0
- aas_core_codegen/parse/tree.py +1303 -0
- aas_core_codegen/protobuf/__init__.py +1 -0
- aas_core_codegen/protobuf/common.py +225 -0
- aas_core_codegen/protobuf/description.py +1102 -0
- aas_core_codegen/protobuf/main.py +115 -0
- aas_core_codegen/protobuf/naming.py +143 -0
- aas_core_codegen/protobuf/structure/__init__.py +6 -0
- aas_core_codegen/protobuf/structure/_generate.py +502 -0
- aas_core_codegen/py.typed +1 -0
- aas_core_codegen/python/__init__.py +1 -0
- aas_core_codegen/python/aas_common/__init__.py +4 -0
- aas_core_codegen/python/aas_common/_generate.py +63 -0
- aas_core_codegen/python/common.py +406 -0
- aas_core_codegen/python/constants/__init__.py +5 -0
- aas_core_codegen/python/constants/_generate.py +377 -0
- aas_core_codegen/python/description.py +508 -0
- aas_core_codegen/python/jsonization/__init__.py +4 -0
- aas_core_codegen/python/jsonization/_generate.py +1391 -0
- aas_core_codegen/python/main.py +323 -0
- aas_core_codegen/python/naming.py +255 -0
- aas_core_codegen/python/stringification/__init__.py +4 -0
- aas_core_codegen/python/stringification/_generate.py +129 -0
- aas_core_codegen/python/structure/__init__.py +6 -0
- aas_core_codegen/python/structure/_generate.py +1801 -0
- aas_core_codegen/python/transpilation.py +958 -0
- aas_core_codegen/python/unrolling.py +156 -0
- aas_core_codegen/python/verification/__init__.py +6 -0
- aas_core_codegen/python/verification/_generate.py +1471 -0
- aas_core_codegen/python/xmlization/__init__.py +4 -0
- aas_core_codegen/python/xmlization/_generate.py +3003 -0
- aas_core_codegen/python_protobuf/__init__.py +1 -0
- aas_core_codegen/python_protobuf/main.py +1424 -0
- aas_core_codegen/python_protobuf/naming.py +85 -0
- aas_core_codegen/rdf_shacl/__init__.py +1 -0
- aas_core_codegen/rdf_shacl/_description.py +351 -0
- aas_core_codegen/rdf_shacl/common.py +206 -0
- aas_core_codegen/rdf_shacl/main.py +114 -0
- aas_core_codegen/rdf_shacl/naming.py +145 -0
- aas_core_codegen/rdf_shacl/rdf.py +435 -0
- aas_core_codegen/rdf_shacl/shacl.py +453 -0
- aas_core_codegen/run.py +124 -0
- aas_core_codegen/smoke/__init__.py +1 -0
- aas_core_codegen/smoke/main.py +219 -0
- aas_core_codegen/specific_implementations.py +72 -0
- aas_core_codegen/stringify.py +333 -0
- aas_core_codegen/typescript/__init__.py +1 -0
- aas_core_codegen/typescript/aas_common/__init__.py +4 -0
- aas_core_codegen/typescript/aas_common/_generate.py +472 -0
- aas_core_codegen/typescript/common.py +340 -0
- aas_core_codegen/typescript/constants/__init__.py +5 -0
- aas_core_codegen/typescript/constants/_generate.py +347 -0
- aas_core_codegen/typescript/description.py +530 -0
- aas_core_codegen/typescript/jsonization/__init__.py +4 -0
- aas_core_codegen/typescript/jsonization/_generate.py +1510 -0
- aas_core_codegen/typescript/main.py +258 -0
- aas_core_codegen/typescript/naming.py +189 -0
- aas_core_codegen/typescript/stringification/__init__.py +4 -0
- aas_core_codegen/typescript/stringification/_generate.py +367 -0
- aas_core_codegen/typescript/structure/__init__.py +6 -0
- aas_core_codegen/typescript/structure/_generate.py +2500 -0
- aas_core_codegen/typescript/transpilation.py +1051 -0
- aas_core_codegen/typescript/unrolling.py +159 -0
- aas_core_codegen/typescript/verification/__init__.py +6 -0
- aas_core_codegen/typescript/verification/_generate.py +1578 -0
- aas_core_codegen/xsd/__init__.py +1 -0
- aas_core_codegen/xsd/main.py +1187 -0
- aas_core_codegen/xsd/naming.py +83 -0
- aas_core_codegen/yielding/__init__.py +1 -0
- aas_core_codegen/yielding/flow.py +139 -0
- aas_core_codegen/yielding/linear.py +754 -0
- aas_core_codegen-0.0.16.dist-info/METADATA +211 -0
- aas_core_codegen-0.0.16.dist-info/RECORD +604 -0
- aas_core_codegen-0.0.16.dist-info/WHEEL +5 -0
- aas_core_codegen-0.0.16.dist-info/entry_points.txt +3 -0
- aas_core_codegen-0.0.16.dist-info/licenses/AUTHORS +9 -0
- aas_core_codegen-0.0.16.dist-info/licenses/LICENSE +23 -0
- aas_core_codegen-0.0.16.dist-info/top_level.txt +2 -0
- dev/continuous_integration/__init__.py +1 -0
- dev/continuous_integration/check_help_in_readme.py +208 -0
- dev/continuous_integration/check_init_and_pyproject_consistent.py +154 -0
- dev/continuous_integration/precommit.py +400 -0
- dev/dev_scripts/__init__.py +1 -0
- dev/dev_scripts/compare_rendered_regexes_against_source_py.py +42 -0
- dev/dev_scripts/copy_to_aas_core3_cpp.py +100 -0
- dev/dev_scripts/copy_to_aas_core3_java.py +90 -0
- dev/dev_scripts/download_latest_aas_core_meta_v3.py +114 -0
- dev/dev_scripts/draw_bipartite_graph_based_on_lines.py +37 -0
- dev/dev_scripts/run_tests_with_rerecord.py +69 -0
- dev/dev_scripts/update_to_aas_core_meta.py +174 -0
- dev/integration_tests/input/jsonschema/boilerplate/main.py +55 -0
- dev/integration_tests/input/meta_model.py +38 -0
- dev/integration_tests/input/python/boilerplate/main.py +153 -0
- dev/integration_tests/main.py +258 -0
- dev/test_data/csharp/test_structure/concrete_class_with_descendants/meta_model.py +15 -0
- dev/test_data/csharp/test_structure/constructor_without_arguments/all_properties_optional/meta_model.py +9 -0
- dev/test_data/csharp/test_structure/constructor_without_arguments/no_properties/meta_model.py +6 -0
- dev/test_data/csharp/test_verification/builtin_functions/len/on_list/meta_model.py +20 -0
- dev/test_data/csharp/test_verification/builtin_functions/len/on_str/meta_model.py +16 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_prefix/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_suffix/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_group_with_quantifier/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_the_middle/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_union/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/single_utf32_literal/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_within_group/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_without_group/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_beginning/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_end/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/in_the_middle/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/multiple/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single_with_quantifier/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/mixed_with_non_utf32/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/more_than_two_high_surrogates/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/multiple_utf32_ranges/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/multiple_utf32_ranges_mixed_with_non_utf32/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate_with_quantifier/meta_model.py +8 -0
- dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/two_high_surrogates/meta_model.py +8 -0
- dev/test_data/intermediate/expected/class/empty/meta_model.py +6 -0
- dev/test_data/intermediate/expected/class/implementation_specific_method/meta_model.py +8 -0
- dev/test_data/intermediate/expected/class/inheritance/meta_model.py +41 -0
- dev/test_data/intermediate/expected/class/methods_with_contracts/meta_model.py +15 -0
- dev/test_data/intermediate/expected/class/only_method_no_property/meta_model.py +7 -0
- dev/test_data/intermediate/expected/class/only_property_no_method/meta_model.py +9 -0
- dev/test_data/intermediate/expected/constant/constant_set/of_enum/meta_model.py +12 -0
- dev/test_data/intermediate/expected/constant/constant_set/of_str/meta_model.py +4 -0
- dev/test_data/intermediate/expected/constant/constant_set/with_description/meta_model.py +6 -0
- dev/test_data/intermediate/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
- dev/test_data/intermediate/expected/constant/constant_str/only_value/meta_model.py +7 -0
- dev/test_data/intermediate/expected/constant/constant_str/with_description/meta_model.py +5 -0
- dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_in_literal/meta_model.py +20 -0
- dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_outside_literal/meta_model.py +20 -0
- dev/test_data/intermediate/expected/empty/meta_model.py +2 -0
- dev/test_data/intermediate/expected/enumeration/meta_model.py +9 -0
- dev/test_data/intermediate/expected/interface/basic/meta_model.py +14 -0
- dev/test_data/intermediate/expected/interface/empty/meta_model.py +7 -0
- dev/test_data/intermediate/expected/interface/inheritance/meta_model.py +27 -0
- dev/test_data/intermediate/expected/interface/method_signature/meta_model.py +10 -0
- dev/test_data/intermediate/expected/interface/only_constructor/meta_model.py +11 -0
- dev/test_data/intermediate/expected/method/non_mutating/implementation_specific/meta_model.py +12 -0
- dev/test_data/intermediate/expected/method/non_mutating/understood/meta_model.py +11 -0
- dev/test_data/intermediate/expected/type_annotation/atomic/meta_model.py +9 -0
- dev/test_data/intermediate/expected/type_annotation/subscripted/class/meta_model.py +13 -0
- dev/test_data/intermediate/expected/type_annotation/subscripted/primitive/meta_model.py +9 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/enumeration_literals_in_subset_outside_of_superset/meta_model.py +20 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/invalid_literal/meta_model.py +11 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_between_enumeration_and_literal/meta_model.py +30 -0
- dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_in_enumerations_between_subset_and_superset/meta_model.py +21 -0
- dev/test_data/intermediate/unexpected/constant_set/of_str/literals_in_subset_outside_of_superset/meta_model.py +18 -0
- dev/test_data/intermediate/unexpected/constant_set/of_str/mismatch_between_type_annotation_and_literals/meta_model.py +10 -0
- dev/test_data/intermediate/unexpected/constant_set/of_str/superset_and_subset_mismatch_in_type/meta_model.py +12 -0
- dev/test_data/intermediate/unexpected/constraints/dangling_constraintref/meta_model.py +18 -0
- dev/test_data/intermediate/unexpected/constraints/duplicate_constraints/meta_model.py +20 -0
- dev/test_data/intermediate/unexpected/documentation/unexpected_documentation_elements/meta_model.py +34 -0
- dev/test_data/intermediate/unexpected/invariant/class_invariant_uses_re/meta_model.py +10 -0
- dev/test_data/intermediate/unexpected/invariant/invariant_of_constrained_primitive_uses_re/meta_model.py +7 -0
- dev/test_data/intermediate/unexpected/invariant/unexpected_argument_count_to_len/meta_model.py +20 -0
- dev/test_data/intermediate/unexpected/invariant/unhandled_built_in_function/meta_model.py +16 -0
- dev/test_data/intermediate/unexpected/method_definitions/non_constant_default/meta_model.py +7 -0
- dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/default_non_none/meta_model.py +16 -0
- dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/no_default/meta_model.py +16 -0
- dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/after_inheritance/meta_model.py +58 -0
- dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/type_missmatch/meta_model.py +9 -0
- dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/within_class/meta_model.py +22 -0
- dev/test_data/jsonschema/test_main/regression_when_len_constraints_on_inherited_property/meta_model.py +28 -0
- dev/test_data/opcua/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
- dev/test_data/opcua/test_main/classes_with_invariants/meta_model.py +21 -0
- dev/test_data/opcua/test_main/concrete_class_with_descendant/meta_model.py +27 -0
- dev/test_data/opcua/test_main/concrete_class_with_enum/meta_model.py +21 -0
- dev/test_data/opcua/test_main/concrete_class_with_list_of_instances/meta_model.py +21 -0
- dev/test_data/opcua/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
- dev/test_data/opcua/test_main/concrete_class_with_string/meta_model.py +13 -0
- dev/test_data/opcua/test_main/constrained_primitive/meta_model.py +20 -0
- dev/test_data/opcua/test_main/multiple_inheritance/meta_model.py +25 -0
- dev/test_data/parse/expected/constant/constant_set/of_enum/meta_model.py +12 -0
- dev/test_data/parse/expected/constant/constant_set/of_str/meta_model.py +4 -0
- dev/test_data/parse/expected/constant/constant_set/with_description/meta_model.py +6 -0
- dev/test_data/parse/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
- dev/test_data/parse/expected/constant/constant_str/only_value/meta_model.py +7 -0
- dev/test_data/parse/expected/constant/constant_str/with_description/meta_model.py +5 -0
- dev/test_data/parse/expected/enum/ok/meta_model.py +15 -0
- dev/test_data/parse/expected/implementation_specific_class/properties_and_methods_in_implementation_specific_class/meta_model.py +17 -0
- dev/test_data/parse/expected/inheritance/basic/meta_model.py +11 -0
- dev/test_data/parse/expected/inheritance/diamond/meta_model.py +26 -0
- dev/test_data/parse/expected/inheritance/inheritance_from_concrete_class/meta_model.py +10 -0
- dev/test_data/parse/expected/invariants/in_relation/meta_model.py +16 -0
- dev/test_data/parse/expected/method/arguments/meta_model.py +7 -0
- dev/test_data/parse/expected/method/basic/meta_model.py +7 -0
- dev/test_data/parse/expected/method/contracts/condition_as_keyword_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/condition_as_positional_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/description_as_keyword_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/description_as_positional_argument/meta_model.py +8 -0
- dev/test_data/parse/expected/method/contracts/multiple_contracts_in_order/meta_model.py +17 -0
- dev/test_data/parse/expected/method/contracts/postcondition/basic/meta_model.py +10 -0
- dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_keyword_arguments/meta_model.py +9 -0
- dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_positional_arguments/meta_model.py +9 -0
- dev/test_data/parse/expected/method/default/meta_model.py +9 -0
- dev/test_data/parse/expected/method/description/meta_model.py +8 -0
- dev/test_data/parse/expected/method/is_implementation_specific/meta_model.py +8 -0
- dev/test_data/parse/expected/method/non_mutating/meta_model.py +11 -0
- dev/test_data/parse/expected/method/returns_none/meta_model.py +7 -0
- dev/test_data/parse/expected/method/returns_something/meta_model.py +7 -0
- dev/test_data/parse/expected/single_class/description/meta_model.py +12 -0
- dev/test_data/parse/expected/single_class/empty/meta_model.py +6 -0
- dev/test_data/parse/expected/single_class/property/description/meta_model.py +14 -0
- dev/test_data/parse/expected/single_class/property/mandatory/meta_model.py +6 -0
- dev/test_data/parse/expected/single_class/property/optional/meta_model.py +6 -0
- dev/test_data/parse/expected/single_class/property/recursion_to_entity/meta_model.py +6 -0
- dev/test_data/parse/unexpected/class_decorators/non_name_decorator/meta_model.py +7 -0
- dev/test_data/parse/unexpected/class_decorators/unknown_decorator/meta_model.py +7 -0
- dev/test_data/parse/unexpected/class_definitions/is_abstract_and_implementation_specific/meta_model.py +8 -0
- dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_before_a_method/meta_model.py +11 -0
- dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_for_a_pass/meta_model.py +9 -0
- dev/test_data/parse/unexpected/class_definitions/unexpected_double_description_for_a_property/meta_model.py +10 -0
- dev/test_data/parse/unexpected/class_inheritances/inheriting_from_implementation_specific_parent/meta_model.py +20 -0
- dev/test_data/parse/unexpected/class_inheritances/non_name_super_class/meta_model.py +6 -0
- dev/test_data/parse/unexpected/enum/expression_as_assignment_value/meta_model.py +6 -0
- dev/test_data/parse/unexpected/enum/non_assignment/meta_model.py +8 -0
- dev/test_data/parse/unexpected/enum/non_string_literal/meta_model.py +6 -0
- dev/test_data/parse/unexpected/enum/unexpected_inheritance/meta_model.py +6 -0
- dev/test_data/parse/unexpected/method_contracts/contract/non_lambda_condition/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/contract/non_string_literal_description/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/contract/without_any_arguments/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/contract/without_condition/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/postcondition/OLD_in_postcondition_without_snapshot/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/postcondition/argument_missing_in_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/precondition/argument_missing_in_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/argument_missing_in_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/capture_not_a_lambda/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/invalid_name/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/name_not_a_string_literal/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_capture/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_name/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_constructor/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_verification_function/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/non_name_decorator/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/unknown_call_decorator/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_decorators/unknown_name_decorator/meta_model.py +8 -0
- dev/test_data/parse/unexpected/method_definitions/argument_with_final/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/argument_without_a_type_annotation/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/default_for_self/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/dunder/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/init_with_return_type/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_keyword_only_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_positional_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_type_annotation_for_self/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_variable_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/with_variable_keyword_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/without_arguments/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/without_self/meta_model.py +7 -0
- dev/test_data/parse/unexpected/method_definitions/without_type_annotation_for_result/meta_model.py +7 -0
- dev/test_data/parse/unexpected/property_definitions/final_without_subscript/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/nested_final/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/non_simple/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/unexpected_assignment/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/unexpected_non_name_property/meta_model.py +6 -0
- dev/test_data/parse/unexpected/property_definitions/without_type_annotation/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/constant_set_with_a_non_set_subset/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_inheritance/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_a_property/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_an_argument/meta_model.py +7 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_constant_set/meta_model.py +6 -0
- dev/test_data/parse/unexpected/symbol_table/dangling_subset_in_constant_set/meta_model.py +4 -0
- dev/test_data/parse/unexpected/symbol_table/inheritance_from_non_class/meta_model.py +10 -0
- dev/test_data/parse_retree/expected/character_set/common_escaping/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/complementing/double_caret/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/complementing/multiple_ranges/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/complementing/suffix_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/escape_first_caret/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/literals_which_need_no_escaping_in_characters_set_but_need_escaping_outside/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/multiple_ranges/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/single_literal/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/single_range/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/unescaped_dash/only_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/unescaped_dash/prefix_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/character_set/unescaped_dash/suffix_dash/source.py +1 -0
- dev/test_data/parse_retree/expected/dot/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/group/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/group_in_a_group/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/group_of_union_of_empty_concatenations/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/regex/source.py +1 -0
- dev/test_data/parse_retree/expected/empty/union_of_empty_concatenations/source.py +1 -0
- dev/test_data/parse_retree/expected/escaped_literals/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/at_the_beginning/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/at_the_end/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/in_the_middle/source.py +1 -0
- dev/test_data/parse_retree/expected/formatted_value/single_formatted_value/source.py +1 -0
- dev/test_data/parse_retree/expected/literal/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/at_least_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/at_least_one/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/at_most_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/exactly_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/maybe/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/greedy/zero_or_more/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_one/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/at_most_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/exactly_3/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/maybe/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/non_greedy/zero_or_more/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_character_set/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_formatted_value/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_group/source.py +1 -0
- dev/test_data/parse_retree/expected/quantifier/on_a_literal/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/double_end_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/double_start_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/end_symbol_in_the_middle/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/only_start_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/only_stop_symbol/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_at_the_beginning/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_in_the_middle/source.py +1 -0
- dev/test_data/parse_retree/expected/start_and_stop_symbols/stop_symbol_at_the_end/source.py +1 -0
- dev/test_data/parse_retree/expected/union/of_character_sets/source.py +1 -0
- dev/test_data/parse_retree/expected/union/of_groups/source.py +1 -0
- dev/test_data/parse_retree/expected/union/of_string_literals/source.py +1 -0
- dev/test_data/parse_retree/expected/union/within_group/source.py +1 -0
- dev/test_data/parse_retree/expected/whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/Uxxxxxxxx_out_of_range/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/only_backslash/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_Uxxxxxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_uxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unexpected_escaping/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/Uxxxxxxxx_out_of_range/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/only_backslash/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_Uxxxxxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_uxxxx/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unexpected_escaping/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_digit/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/whitespace/source.py +1 -0
- dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/word/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_character_range/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_quantifier/at_least_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_quantifier/between_3_and_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/invalid_quantifier/exactly_x/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unhandled_group_directives/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/character_set/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/group/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/group_of_union_of_empty_concatenations/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/quantifier/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_comma/source.py +1 -0
- dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_number_and_comma/source.py +1 -0
- dev/test_data/proto/test_main/expected/abstract_and_concrete_classes/meta_model.py +37 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_descendants/meta_model.py +30 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_enum/meta_model.py +21 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_list_of_instances/meta_model.py +21 -0
- dev/test_data/proto/test_main/expected/concrete_class_with_primitive_attributes/meta_model.py +41 -0
- dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/expected_output/pbization.py +532 -0
- dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/expected_output/pbization.py +527 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/meta_model.py +27 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_enum/expected_output/pbization.py +290 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_enum/meta_model.py +21 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/expected_output/pbization.py +328 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/meta_model.py +23 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/expected_output/pbization.py +274 -0
- dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
- dev/test_data/rdf_shacl/test_main/expected/regression_when_lang_string_class_is_missing/meta_model.py +29 -0
- dev/test_data/rdf_shacl/test_main/expected/regression_when_len_constraints_on_inherited_property/meta_model.py +27 -0
- dev/test_data/rdf_shacl/test_main/unexpected/regression_len_constraint_on_class_property/meta_model.py +61 -0
- dev/test_data/real_meta_models/aas_core_meta.v3.py +5721 -0
- dev/test_data/smoke/test_main/unexpected/infer_for_schema_error/meta_model.py +12 -0
- dev/test_data/smoke/test_main/unexpected/intermediate_error/meta_model.py +18 -0
- dev/test_data/smoke/test_main/unexpected/parse_error/meta_model.py +5 -0
- dev/test_data/smoke/test_main/unexpected/pattern_verification_unparsable_regex/direct_match/meta_model.py +8 -0
- dev/test_data/smoke/test_main/unexpected/type_error/meta_model.py +18 -0
- dev/tests/__init__.py +1 -0
- dev/tests/common.py +197 -0
- dev/tests/cpp/__init__.py +0 -0
- dev/tests/cpp/test_common.py +32 -0
- dev/tests/cpp/test_main.py +144 -0
- dev/tests/cpp/test_pattern.py +188 -0
- dev/tests/cpp/test_verification.py +189 -0
- dev/tests/cpp/test_yielding.py +225 -0
- dev/tests/csharp/__init__.py +0 -0
- dev/tests/csharp/live_test_main.py +109 -0
- dev/tests/csharp/test_common.py +28 -0
- dev/tests/csharp/test_description.py +684 -0
- dev/tests/csharp/test_main.py +129 -0
- dev/tests/csharp/test_structure.py +93 -0
- dev/tests/csharp/test_verification.py +82 -0
- dev/tests/description.py +29 -0
- dev/tests/golang/__init__.py +0 -0
- dev/tests/golang/test_common.py +78 -0
- dev/tests/golang/test_main.py +128 -0
- dev/tests/infer_for_schema/__init__.py +0 -0
- dev/tests/infer_for_schema/common.py +47 -0
- dev/tests/infer_for_schema/test_len_on_properties.py +955 -0
- dev/tests/infer_for_schema/test_len_on_self.py +580 -0
- dev/tests/infer_for_schema/test_patterns_on_properties.py +686 -0
- dev/tests/infer_for_schema/test_patterns_on_self.py +258 -0
- dev/tests/infer_for_schema/test_property_in_set_of_enumeration_literals.py +600 -0
- dev/tests/infer_for_schema/test_property_in_set_of_primitives.py +549 -0
- dev/tests/intermediate/__init__.py +0 -0
- dev/tests/intermediate/test_constructor.py +719 -0
- dev/tests/intermediate/test_hierarchy.py +221 -0
- dev/tests/intermediate/test_revm.py +134 -0
- dev/tests/intermediate/test_translate.py +337 -0
- dev/tests/intermediate/test_type_inference.py +333 -0
- dev/tests/intermediate/test_types.py +169 -0
- dev/tests/java/__init__.py +0 -0
- dev/tests/java/test_common.py +20 -0
- dev/tests/java/test_description.py +128 -0
- dev/tests/java/test_main.py +234 -0
- dev/tests/jsonld_context/test_main.py +79 -0
- dev/tests/opcua/__init__.py +3 -0
- dev/tests/opcua/test_main.py +110 -0
- dev/tests/our_jsonschema/__init__.py +3 -0
- dev/tests/our_jsonschema/test_main.py +232 -0
- dev/tests/parse/__init__.py +0 -0
- dev/tests/parse/test_parse.py +503 -0
- dev/tests/parse/test_retree.py +272 -0
- dev/tests/proto/__init__.py +0 -0
- dev/tests/proto/test_main.py +112 -0
- dev/tests/python/__init__.py +0 -0
- dev/tests/python/test_common.py +124 -0
- dev/tests/python/test_main.py +126 -0
- dev/tests/python/test_xml_playground.py +254 -0
- dev/tests/python_protobuf/__init__.py +0 -0
- dev/tests/python_protobuf/test_main.py +111 -0
- dev/tests/rdf_shacl/__init__.py +0 -0
- dev/tests/rdf_shacl/test_common.py +32 -0
- dev/tests/rdf_shacl/test_description.py +223 -0
- dev/tests/rdf_shacl/test_main.py +194 -0
- dev/tests/smoke/__init__.py +0 -0
- dev/tests/smoke/test_main.py +83 -0
- dev/tests/test_common.py +94 -0
- dev/tests/typescript/__init__.py +0 -0
- dev/tests/typescript/test_common.py +108 -0
- dev/tests/typescript/test_main.py +125 -0
- dev/tests/xsd/__init__.py +0 -0
- dev/tests/xsd/test_main.py +227 -0
- dev/tests/yielding/__init__.py +0 -0
- dev/tests/yielding/test_linear.py +558 -0
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
"""Understand the constructors of the classes."""
|
|
2
|
+
import abc
|
|
3
|
+
import ast
|
|
4
|
+
import collections
|
|
5
|
+
import itertools
|
|
6
|
+
import pathlib
|
|
7
|
+
from typing import (
|
|
8
|
+
List,
|
|
9
|
+
Optional,
|
|
10
|
+
MutableMapping,
|
|
11
|
+
Mapping,
|
|
12
|
+
Sequence,
|
|
13
|
+
Union,
|
|
14
|
+
Tuple,
|
|
15
|
+
AbstractSet,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
import asttokens
|
|
19
|
+
from icontract import ensure, require, DBC
|
|
20
|
+
|
|
21
|
+
from aas_core_codegen import parse, stringify
|
|
22
|
+
from aas_core_codegen.common import (
|
|
23
|
+
Identifier,
|
|
24
|
+
Error,
|
|
25
|
+
assert_union_of_descendants_exhaustive,
|
|
26
|
+
)
|
|
27
|
+
from aas_core_codegen.parse import Method
|
|
28
|
+
|
|
29
|
+
_MODULE_NAME = pathlib.Path(__file__).parent.name
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class CallSuperConstructor:
|
|
33
|
+
"""
|
|
34
|
+
Represent a call to the constructor of a super class.
|
|
35
|
+
|
|
36
|
+
The arguments of the original ``__init__`` are expected to be propagated as-are.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
super_name: Identifier #: Identifier of the super class
|
|
40
|
+
|
|
41
|
+
def __init__(self, super_name: Identifier) -> None:
|
|
42
|
+
"""Initialize with the given values."""
|
|
43
|
+
self.super_name = super_name
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class Default(DBC):
|
|
47
|
+
"""Represent a default value set to a property if an argument is unspecified."""
|
|
48
|
+
|
|
49
|
+
def __init__(self, node: ast.AST) -> None:
|
|
50
|
+
"""Initialize with the given values."""
|
|
51
|
+
self.node = node
|
|
52
|
+
|
|
53
|
+
@abc.abstractmethod
|
|
54
|
+
def __repr__(self) -> str:
|
|
55
|
+
# Signal that the class is purely abstract
|
|
56
|
+
raise NotImplementedError()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class EmptyList(Default):
|
|
60
|
+
"""Represent an empty list set to a property if the argument is unspecified."""
|
|
61
|
+
|
|
62
|
+
def __repr__(self) -> str:
|
|
63
|
+
"""Represent the instance as a string for easier debugging."""
|
|
64
|
+
return f"<{_MODULE_NAME}.{self.__class__.__name__} at 0x{id(self):x}>"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class DefaultEnumLiteral(Default):
|
|
68
|
+
"""Represent an enum literal set to a property if the argument is unspecified."""
|
|
69
|
+
|
|
70
|
+
@require(lambda enum, literal: literal in enum.literals)
|
|
71
|
+
def __init__(
|
|
72
|
+
self, enum: parse.Enumeration, literal: parse.EnumerationLiteral, node: ast.AST
|
|
73
|
+
) -> None:
|
|
74
|
+
"""Initialize with the given values."""
|
|
75
|
+
Default.__init__(self, node=node)
|
|
76
|
+
self.enum = enum
|
|
77
|
+
self.literal = literal
|
|
78
|
+
|
|
79
|
+
def __repr__(self) -> str:
|
|
80
|
+
"""Represent the instance as a string for easier debugging."""
|
|
81
|
+
return f"<{_MODULE_NAME}.{self.__class__.__name__} at 0x{id(self):x}>"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class AssignArgument:
|
|
85
|
+
"""Represent an assignment of an argument to ``__init__`` to a property."""
|
|
86
|
+
|
|
87
|
+
name: Identifier #: Identifier of the property
|
|
88
|
+
argument: Identifier #: Identifier of the argument
|
|
89
|
+
default: Optional["DefaultUnion"] #: Default value if the argument is None
|
|
90
|
+
|
|
91
|
+
def __init__(
|
|
92
|
+
self, name: Identifier, argument: Identifier, default: Optional["DefaultUnion"]
|
|
93
|
+
) -> None:
|
|
94
|
+
"""Initialize with the given values."""
|
|
95
|
+
self.name = name
|
|
96
|
+
self.argument = argument
|
|
97
|
+
self.default = default
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
Statement = Union[CallSuperConstructor, AssignArgument]
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# noinspection PyTypeChecker
|
|
104
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
105
|
+
def _call_as_call_to_super_init(
|
|
106
|
+
call: ast.Call,
|
|
107
|
+
parsed_class: parse.Class,
|
|
108
|
+
parsed_symbol_table: parse.SymbolTable,
|
|
109
|
+
atok: asttokens.ASTTokens,
|
|
110
|
+
) -> Tuple[Optional[CallSuperConstructor], Optional[Error]]:
|
|
111
|
+
"""Understand a call as a call to the constructor of a super-class."""
|
|
112
|
+
if not isinstance(call.func, ast.Attribute):
|
|
113
|
+
return (
|
|
114
|
+
None,
|
|
115
|
+
Error(
|
|
116
|
+
call,
|
|
117
|
+
f"Unexpected call in the body "
|
|
118
|
+
f"of ``__init__``: {atok.get_text(call.func)}; "
|
|
119
|
+
f"only calls to super ``__init__``'s are expected",
|
|
120
|
+
),
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
if call.func.attr != "__init__":
|
|
124
|
+
return (
|
|
125
|
+
None,
|
|
126
|
+
Error(
|
|
127
|
+
call,
|
|
128
|
+
f"Unexpected call in the body "
|
|
129
|
+
f"of ``__init__``: {atok.get_text(call.func)}; "
|
|
130
|
+
f"only calls to super ``__init__``'s are expected",
|
|
131
|
+
),
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
if not isinstance(call.func.value, ast.Name):
|
|
135
|
+
return (
|
|
136
|
+
None,
|
|
137
|
+
Error(
|
|
138
|
+
call.func.value,
|
|
139
|
+
f"Expected a super class as a name "
|
|
140
|
+
f"for a call to super ``__init__``, "
|
|
141
|
+
f"but got: {atok.get_text(call.func.value)}",
|
|
142
|
+
),
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
identifier = Identifier(call.func.value.id)
|
|
146
|
+
|
|
147
|
+
if identifier not in parsed_class.inheritances:
|
|
148
|
+
return (
|
|
149
|
+
None,
|
|
150
|
+
Error(
|
|
151
|
+
call.func.value,
|
|
152
|
+
f"Expected a super class in the call "
|
|
153
|
+
f"to a super ``__init__``, "
|
|
154
|
+
f"but {parsed_class.name} does not inherit "
|
|
155
|
+
f"from {identifier}",
|
|
156
|
+
),
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
parsed_super_class = parsed_symbol_table.must_find_class(name=identifier)
|
|
160
|
+
|
|
161
|
+
if "__init__" not in parsed_super_class.methods_by_name:
|
|
162
|
+
return (
|
|
163
|
+
None,
|
|
164
|
+
Error(
|
|
165
|
+
call.func,
|
|
166
|
+
f"The super class {parsed_super_class.name} "
|
|
167
|
+
f"does not define a ``__init__``",
|
|
168
|
+
),
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
# region Check the arguments of the call to super ``__init__``
|
|
172
|
+
|
|
173
|
+
double_star_keyword = next(
|
|
174
|
+
(keyword for keyword in call.keywords if keyword.arg is None), None
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
if double_star_keyword is not None:
|
|
178
|
+
return (
|
|
179
|
+
None,
|
|
180
|
+
Error(
|
|
181
|
+
double_star_keyword,
|
|
182
|
+
"Expected a call to a super ``__init__`` to provide only "
|
|
183
|
+
"explicit keyword arguments, "
|
|
184
|
+
"but got a double-star keyword argument",
|
|
185
|
+
),
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
underlying_errors = [] # type: List[Error]
|
|
189
|
+
|
|
190
|
+
for arg_node in itertools.chain(
|
|
191
|
+
call.args, (keyword.value for keyword in call.keywords)
|
|
192
|
+
):
|
|
193
|
+
if not isinstance(arg_node, ast.Name):
|
|
194
|
+
underlying_errors.append(
|
|
195
|
+
Error(
|
|
196
|
+
arg_node,
|
|
197
|
+
f"Expected only names in the arguments to "
|
|
198
|
+
f"super ``__init__``, but got: {atok.get_text(arg_node)}",
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
if len(underlying_errors) > 0:
|
|
203
|
+
return (
|
|
204
|
+
None,
|
|
205
|
+
Error(
|
|
206
|
+
call,
|
|
207
|
+
"Failed to parse the arguments to the super ``__init__``",
|
|
208
|
+
underlying_errors,
|
|
209
|
+
),
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
super_init = parsed_super_class.methods_by_name[Identifier("__init__")]
|
|
213
|
+
resolved_kwargs = dict() # type: MutableMapping[str, str]
|
|
214
|
+
|
|
215
|
+
if len(call.args) > len(super_init.arguments):
|
|
216
|
+
return (
|
|
217
|
+
None,
|
|
218
|
+
Error(
|
|
219
|
+
call,
|
|
220
|
+
f"The ``{parsed_super_class.name}.__init__`` "
|
|
221
|
+
f"expected {len(super_init.arguments)} argument(s), "
|
|
222
|
+
f"but the call provides "
|
|
223
|
+
f"{len(call.args)} positional argument(s)",
|
|
224
|
+
),
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
for arg_node, argument in zip(call.args, super_init.arguments):
|
|
228
|
+
assert isinstance(arg_node, ast.Name)
|
|
229
|
+
resolved_kwargs[argument.name] = arg_node.id
|
|
230
|
+
|
|
231
|
+
assert len(underlying_errors) == 0
|
|
232
|
+
|
|
233
|
+
for keyword in call.keywords:
|
|
234
|
+
if keyword.arg not in super_init.arguments_by_name:
|
|
235
|
+
underlying_errors.append(
|
|
236
|
+
Error(
|
|
237
|
+
keyword,
|
|
238
|
+
f"The ``{parsed_super_class.name}.__init__`` does not expect "
|
|
239
|
+
f"the argument {keyword.arg}",
|
|
240
|
+
)
|
|
241
|
+
)
|
|
242
|
+
else:
|
|
243
|
+
assert isinstance(keyword.value, ast.Name)
|
|
244
|
+
assert isinstance(keyword.arg, str)
|
|
245
|
+
resolved_kwargs[keyword.arg] = keyword.value.id
|
|
246
|
+
|
|
247
|
+
if len(underlying_errors) > 0:
|
|
248
|
+
return (
|
|
249
|
+
None,
|
|
250
|
+
Error(
|
|
251
|
+
call,
|
|
252
|
+
"Failed to parse the arguments to the super ``__init__``",
|
|
253
|
+
underlying_errors,
|
|
254
|
+
),
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
init = parsed_class.methods_by_name[Identifier("__init__")]
|
|
258
|
+
for key, val in resolved_kwargs.items():
|
|
259
|
+
if val not in init.arguments_by_name:
|
|
260
|
+
underlying_errors.append(
|
|
261
|
+
Error(
|
|
262
|
+
call,
|
|
263
|
+
f"Expected all the arguments to "
|
|
264
|
+
f"``{parsed_super_class.name}.__init__`` "
|
|
265
|
+
f"to be propagation of the original ``__init__`` "
|
|
266
|
+
f"arguments, but the name {key} is not an argument "
|
|
267
|
+
f"of ``{parsed_class.name}.__init__``",
|
|
268
|
+
)
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
elif key != val:
|
|
272
|
+
underlying_errors.append(
|
|
273
|
+
Error(
|
|
274
|
+
call,
|
|
275
|
+
f"Expected the arguments to super ``__init__`` "
|
|
276
|
+
f"to be passed with the same names, "
|
|
277
|
+
f"but the argument {key} is passed "
|
|
278
|
+
f"as the name {val}",
|
|
279
|
+
)
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
missing_args = [
|
|
283
|
+
argument.name
|
|
284
|
+
for argument in super_init.arguments
|
|
285
|
+
if argument.name not in resolved_kwargs
|
|
286
|
+
]
|
|
287
|
+
|
|
288
|
+
if len(missing_args) > 0:
|
|
289
|
+
missing_args_str = ", ".join(missing_args)
|
|
290
|
+
underlying_errors.append(
|
|
291
|
+
Error(
|
|
292
|
+
call,
|
|
293
|
+
f"The call to ``{parsed_super_class.name}.__init__`` "
|
|
294
|
+
f"is missing one or more arguments: "
|
|
295
|
+
f"{missing_args_str}",
|
|
296
|
+
)
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
if len(underlying_errors) > 0:
|
|
300
|
+
return (
|
|
301
|
+
None,
|
|
302
|
+
Error(
|
|
303
|
+
call,
|
|
304
|
+
"Failed to parse the arguments to the super ``__init__``",
|
|
305
|
+
underlying_errors,
|
|
306
|
+
),
|
|
307
|
+
)
|
|
308
|
+
# endregion
|
|
309
|
+
|
|
310
|
+
return CallSuperConstructor(super_name=parsed_super_class.name), None
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
# noinspection PyTypeChecker
|
|
314
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
315
|
+
def _understand_assignment(
|
|
316
|
+
assign: ast.Assign,
|
|
317
|
+
init: Method,
|
|
318
|
+
parsed_class: parse.Class,
|
|
319
|
+
parsed_symbol_table: parse.SymbolTable,
|
|
320
|
+
atok: asttokens.ASTTokens,
|
|
321
|
+
) -> Tuple[Optional[Statement], Optional[Error]]:
|
|
322
|
+
if len(assign.targets) > 1:
|
|
323
|
+
return (
|
|
324
|
+
None,
|
|
325
|
+
Error(
|
|
326
|
+
assign,
|
|
327
|
+
f"Expected only a single target for property assignment, "
|
|
328
|
+
f"but got {len(assign.targets)} targets",
|
|
329
|
+
),
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
target = assign.targets[0]
|
|
333
|
+
|
|
334
|
+
if not (
|
|
335
|
+
isinstance(target, ast.Attribute)
|
|
336
|
+
and isinstance(target.value, ast.Name)
|
|
337
|
+
and target.value.id == "self"
|
|
338
|
+
):
|
|
339
|
+
return (
|
|
340
|
+
None,
|
|
341
|
+
Error(
|
|
342
|
+
target,
|
|
343
|
+
f"Expected a property as the target of an assignment, "
|
|
344
|
+
f"but got: {atok.get_text(target)}",
|
|
345
|
+
),
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
if target.attr not in parsed_class.properties_by_name:
|
|
349
|
+
return (
|
|
350
|
+
None,
|
|
351
|
+
Error(
|
|
352
|
+
target.value,
|
|
353
|
+
f"The property has not been previously "
|
|
354
|
+
f"defined in the class {parsed_class.name!r}: {target.attr}",
|
|
355
|
+
),
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
if isinstance(assign.value, ast.Name):
|
|
359
|
+
if assign.value.id not in init.arguments_by_name:
|
|
360
|
+
return (
|
|
361
|
+
None,
|
|
362
|
+
Error(
|
|
363
|
+
assign.value,
|
|
364
|
+
f"Expected the property {target.attr} to be assigned "
|
|
365
|
+
f"to an argument, but it was assigned to a non-argument variable: "
|
|
366
|
+
f"{atok.get_text(assign.value)}",
|
|
367
|
+
),
|
|
368
|
+
)
|
|
369
|
+
|
|
370
|
+
if target.attr != assign.value.id:
|
|
371
|
+
return (
|
|
372
|
+
None,
|
|
373
|
+
Error(
|
|
374
|
+
assign.value,
|
|
375
|
+
f"Expected the property {target.attr} to be assigned "
|
|
376
|
+
f"exactly the argument with the same name, "
|
|
377
|
+
f"but got: {atok.get_text(assign.value)}",
|
|
378
|
+
),
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
return (
|
|
382
|
+
AssignArgument(
|
|
383
|
+
name=Identifier(target.attr),
|
|
384
|
+
argument=Identifier(target.attr),
|
|
385
|
+
default=None,
|
|
386
|
+
),
|
|
387
|
+
None,
|
|
388
|
+
)
|
|
389
|
+
elif isinstance(assign.value, ast.IfExp):
|
|
390
|
+
default_node = None # type: Optional[ast.AST]
|
|
391
|
+
|
|
392
|
+
if_exp = assign.value
|
|
393
|
+
# noinspection PyUnresolvedReferences
|
|
394
|
+
if (
|
|
395
|
+
isinstance(if_exp.test, ast.Compare)
|
|
396
|
+
and isinstance(if_exp.test.left, ast.Name)
|
|
397
|
+
and isinstance(if_exp.test.left.ctx, ast.Load)
|
|
398
|
+
and if_exp.test.left.id in init.arguments_by_name
|
|
399
|
+
and len(if_exp.test.ops) == 1
|
|
400
|
+
and isinstance(if_exp.test.ops[0], ast.IsNot)
|
|
401
|
+
and len(if_exp.test.comparators) == 1
|
|
402
|
+
and isinstance(if_exp.test.comparators[0], ast.Constant)
|
|
403
|
+
and if_exp.test.comparators[0].value is None
|
|
404
|
+
and isinstance(if_exp.body, ast.Name)
|
|
405
|
+
and if_exp.body.id == if_exp.test.left.id
|
|
406
|
+
and if_exp.orelse is not None
|
|
407
|
+
):
|
|
408
|
+
default_node = if_exp.orelse
|
|
409
|
+
|
|
410
|
+
elif (
|
|
411
|
+
isinstance(if_exp.test, ast.Compare)
|
|
412
|
+
and isinstance(if_exp.test.left, ast.Name)
|
|
413
|
+
and if_exp.test.left.id in init.arguments_by_name
|
|
414
|
+
and len(if_exp.test.ops) == 1
|
|
415
|
+
and isinstance(if_exp.test.ops[0], ast.Is)
|
|
416
|
+
and len(if_exp.test.comparators) == 1
|
|
417
|
+
and isinstance(if_exp.test.comparators[0], ast.Constant)
|
|
418
|
+
and if_exp.test.comparators[0].value is None
|
|
419
|
+
and isinstance(if_exp.orelse, ast.Name)
|
|
420
|
+
and if_exp.orelse.id == if_exp.test.left.id
|
|
421
|
+
and if_exp.body is not None
|
|
422
|
+
):
|
|
423
|
+
default_node = if_exp.body
|
|
424
|
+
else:
|
|
425
|
+
# We did not match this case.
|
|
426
|
+
pass
|
|
427
|
+
|
|
428
|
+
if default_node is not None:
|
|
429
|
+
default = None # type: Optional[DefaultUnion]
|
|
430
|
+
|
|
431
|
+
if isinstance(default_node, ast.List) and default_node.elts == []:
|
|
432
|
+
default = EmptyList(node=default_node)
|
|
433
|
+
|
|
434
|
+
elif isinstance(default_node, ast.Attribute) and isinstance(
|
|
435
|
+
default_node.value, ast.Name
|
|
436
|
+
):
|
|
437
|
+
our_type = parsed_symbol_table.find_our_type(
|
|
438
|
+
name=Identifier(default_node.value.id)
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
if isinstance(our_type, parse.Enumeration):
|
|
442
|
+
literal = our_type.literals_by_name.get(
|
|
443
|
+
Identifier(default_node.attr), None
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
if literal is not None:
|
|
447
|
+
default = DefaultEnumLiteral(
|
|
448
|
+
enum=our_type, literal=literal, node=default_node
|
|
449
|
+
)
|
|
450
|
+
else:
|
|
451
|
+
assert default is None
|
|
452
|
+
|
|
453
|
+
if default is None:
|
|
454
|
+
return None, Error(
|
|
455
|
+
if_exp.orelse,
|
|
456
|
+
f"The handling of this default value for "
|
|
457
|
+
f"the property {target.attr!r} has not been implemented: "
|
|
458
|
+
f"{ast.dump(default_node)}",
|
|
459
|
+
)
|
|
460
|
+
else:
|
|
461
|
+
assert isinstance(if_exp.test, ast.Compare)
|
|
462
|
+
assert isinstance(if_exp.test.left, ast.Name)
|
|
463
|
+
|
|
464
|
+
return (
|
|
465
|
+
AssignArgument(
|
|
466
|
+
name=Identifier(target.attr),
|
|
467
|
+
argument=Identifier(if_exp.test.left.id),
|
|
468
|
+
default=default,
|
|
469
|
+
),
|
|
470
|
+
None,
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
return None, Error(
|
|
474
|
+
assign,
|
|
475
|
+
f"The handling of the constructor statement "
|
|
476
|
+
f"has not been implemented: {ast.dump(assign)}; "
|
|
477
|
+
f"please notify the developers if you really need this feature",
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
# noinspection PyTypeChecker
|
|
482
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
483
|
+
def _understand_body(
|
|
484
|
+
parsed_class: parse.Class,
|
|
485
|
+
parsed_symbol_table: parse.SymbolTable,
|
|
486
|
+
atok: asttokens.ASTTokens,
|
|
487
|
+
) -> Tuple[Optional[List[Statement]], Optional[Error]]:
|
|
488
|
+
"""Try to understand the body of the constructor for the given ``parsed_class``."""
|
|
489
|
+
init = None # type: Optional[parse.Method]
|
|
490
|
+
for method in parsed_class.methods:
|
|
491
|
+
if method.name == "__init__":
|
|
492
|
+
init = method
|
|
493
|
+
break
|
|
494
|
+
|
|
495
|
+
if init is None:
|
|
496
|
+
return [], None
|
|
497
|
+
|
|
498
|
+
errors = [] # type: List[Error]
|
|
499
|
+
result = [] # type: List[Statement]
|
|
500
|
+
|
|
501
|
+
assert isinstance(init.node, ast.FunctionDef)
|
|
502
|
+
|
|
503
|
+
for stmt in init.node.body:
|
|
504
|
+
if isinstance(stmt, ast.Pass):
|
|
505
|
+
continue
|
|
506
|
+
elif isinstance(stmt, ast.Expr) and isinstance(stmt.value, ast.Call):
|
|
507
|
+
call_super_init, error = _call_as_call_to_super_init(
|
|
508
|
+
call=stmt.value,
|
|
509
|
+
parsed_class=parsed_class,
|
|
510
|
+
parsed_symbol_table=parsed_symbol_table,
|
|
511
|
+
atok=atok,
|
|
512
|
+
)
|
|
513
|
+
|
|
514
|
+
if error is not None:
|
|
515
|
+
errors.append(error)
|
|
516
|
+
else:
|
|
517
|
+
assert call_super_init is not None
|
|
518
|
+
result.append(call_super_init)
|
|
519
|
+
|
|
520
|
+
elif isinstance(stmt, ast.Assign):
|
|
521
|
+
prop_assignment, error = _understand_assignment(
|
|
522
|
+
assign=stmt,
|
|
523
|
+
init=init,
|
|
524
|
+
parsed_class=parsed_class,
|
|
525
|
+
parsed_symbol_table=parsed_symbol_table,
|
|
526
|
+
atok=atok,
|
|
527
|
+
)
|
|
528
|
+
|
|
529
|
+
if error is not None:
|
|
530
|
+
errors.append(error)
|
|
531
|
+
else:
|
|
532
|
+
assert prop_assignment is not None
|
|
533
|
+
result.append(prop_assignment)
|
|
534
|
+
else:
|
|
535
|
+
errors.append(
|
|
536
|
+
Error(
|
|
537
|
+
stmt,
|
|
538
|
+
f"Unexpected statement in the body "
|
|
539
|
+
f"of ``__init__``: {atok.get_text(stmt)}; "
|
|
540
|
+
f"only calls to super ``__init__``'s and "
|
|
541
|
+
f"property assignments expected",
|
|
542
|
+
)
|
|
543
|
+
)
|
|
544
|
+
|
|
545
|
+
if len(errors) > 0:
|
|
546
|
+
return (
|
|
547
|
+
None,
|
|
548
|
+
Error(
|
|
549
|
+
init.node,
|
|
550
|
+
f"Failed to understand the constructor "
|
|
551
|
+
f"of the class {parsed_class.name}",
|
|
552
|
+
underlying=errors,
|
|
553
|
+
),
|
|
554
|
+
)
|
|
555
|
+
|
|
556
|
+
return result, None
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
class ConstructorTable:
|
|
560
|
+
"""Map understanding of constructors for the classes."""
|
|
561
|
+
|
|
562
|
+
def __init__(self, mapping: Mapping[parse.Class, Sequence[Statement]]) -> None:
|
|
563
|
+
self._mapping = mapping
|
|
564
|
+
|
|
565
|
+
def has(self, parsed_class: parse.Class) -> bool:
|
|
566
|
+
"""Check if there is an entry in the table for the given ``parsed_class``."""
|
|
567
|
+
return parsed_class in self._mapping
|
|
568
|
+
|
|
569
|
+
def must_find(self, parsed_class: parse.Class) -> Sequence[Statement]:
|
|
570
|
+
"""
|
|
571
|
+
Find the constructor corresponding to this ``parsed_class``.
|
|
572
|
+
|
|
573
|
+
:raise: :py:attr:`KeyError` if the entry does not exist.
|
|
574
|
+
"""
|
|
575
|
+
result = self._mapping.get(parsed_class, None)
|
|
576
|
+
if result is None:
|
|
577
|
+
raise KeyError(
|
|
578
|
+
f"No entry found in the constructor table for the class: {parsed_class}"
|
|
579
|
+
)
|
|
580
|
+
|
|
581
|
+
return result
|
|
582
|
+
|
|
583
|
+
def entries(self) -> AbstractSet[Tuple[parse.Class, Sequence[Statement]]]:
|
|
584
|
+
"""Retrieve all the entries in the table."""
|
|
585
|
+
# noinspection PyTypeChecker
|
|
586
|
+
return self._mapping.items()
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
# fmt: off
|
|
590
|
+
@ensure(
|
|
591
|
+
lambda parsed_symbol_table, result:
|
|
592
|
+
result[0] is None
|
|
593
|
+
or all(
|
|
594
|
+
result[0].has(our_type)
|
|
595
|
+
for our_type in parsed_symbol_table.our_types
|
|
596
|
+
if isinstance(our_type, parse.Class)
|
|
597
|
+
),
|
|
598
|
+
"Constructor understood for each class"
|
|
599
|
+
)
|
|
600
|
+
@ensure(lambda result: (result[0] is not None) ^ (result[1] is not None))
|
|
601
|
+
# fmt: on
|
|
602
|
+
def understand_all(
|
|
603
|
+
parsed_symbol_table: parse.SymbolTable, atok: asttokens.ASTTokens
|
|
604
|
+
) -> Tuple[Optional[ConstructorTable], Optional[Error]]:
|
|
605
|
+
"""Understand the constructors of all the classes in the symbol table."""
|
|
606
|
+
errors = [] # type: List[Error]
|
|
607
|
+
mapping = (
|
|
608
|
+
collections.OrderedDict()
|
|
609
|
+
) # type: MutableMapping[parse.Class, List[Statement]]
|
|
610
|
+
|
|
611
|
+
for our_type in parsed_symbol_table.our_types:
|
|
612
|
+
if not isinstance(our_type, parse.Class):
|
|
613
|
+
continue
|
|
614
|
+
|
|
615
|
+
statements, error = _understand_body(
|
|
616
|
+
parsed_class=our_type, parsed_symbol_table=parsed_symbol_table, atok=atok
|
|
617
|
+
)
|
|
618
|
+
|
|
619
|
+
if error is not None:
|
|
620
|
+
errors.append(error)
|
|
621
|
+
else:
|
|
622
|
+
assert statements is not None
|
|
623
|
+
mapping[our_type] = statements
|
|
624
|
+
|
|
625
|
+
if len(errors) > 0:
|
|
626
|
+
return (
|
|
627
|
+
None,
|
|
628
|
+
Error(
|
|
629
|
+
atok.tree, "Failed to understand the constructors", underlying=errors
|
|
630
|
+
),
|
|
631
|
+
)
|
|
632
|
+
|
|
633
|
+
return ConstructorTable(mapping=mapping), None
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
# NOTE (mristin, 2021-12-26):
|
|
637
|
+
# At this point we need to dump only a subset of this module, so we go for YAGNI
|
|
638
|
+
# principle and do not provide dump functions for everything.
|
|
639
|
+
|
|
640
|
+
Dumpable = Union[
|
|
641
|
+
Default,
|
|
642
|
+
EmptyList,
|
|
643
|
+
DefaultEnumLiteral,
|
|
644
|
+
AssignArgument,
|
|
645
|
+
CallSuperConstructor,
|
|
646
|
+
]
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
def _stringify_empty_list(
|
|
650
|
+
that: EmptyList,
|
|
651
|
+
) -> stringify.Entity:
|
|
652
|
+
result = stringify.Entity(
|
|
653
|
+
name=that.__class__.__name__,
|
|
654
|
+
properties=[
|
|
655
|
+
stringify.PropertyEllipsis("node", that.node),
|
|
656
|
+
],
|
|
657
|
+
)
|
|
658
|
+
|
|
659
|
+
return result
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
def _stringify_default_enum_literal(
|
|
663
|
+
that: DefaultEnumLiteral,
|
|
664
|
+
) -> stringify.Entity:
|
|
665
|
+
result = stringify.Entity(
|
|
666
|
+
name=that.__class__.__name__,
|
|
667
|
+
properties=[
|
|
668
|
+
stringify.PropertyEllipsis("node", that.node),
|
|
669
|
+
stringify.Property(
|
|
670
|
+
"enum",
|
|
671
|
+
f"Reference to {that.enum.__class__.__name__} {that.enum.name}",
|
|
672
|
+
),
|
|
673
|
+
stringify.Property(
|
|
674
|
+
"literal",
|
|
675
|
+
f"Reference to {that.literal.__class__.__name__} "
|
|
676
|
+
f"{that.literal.name}",
|
|
677
|
+
),
|
|
678
|
+
],
|
|
679
|
+
)
|
|
680
|
+
|
|
681
|
+
return result
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
def _stringify_assign_argument(
|
|
685
|
+
that: AssignArgument,
|
|
686
|
+
) -> stringify.Entity:
|
|
687
|
+
result = stringify.Entity(
|
|
688
|
+
name=that.__class__.__name__,
|
|
689
|
+
properties=[
|
|
690
|
+
stringify.Property("name", that.name),
|
|
691
|
+
stringify.Property("argument", that.argument),
|
|
692
|
+
stringify.Property("default", _stringify(that.default)),
|
|
693
|
+
],
|
|
694
|
+
)
|
|
695
|
+
|
|
696
|
+
return result
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
def _stringify_call_super_constructor(
|
|
700
|
+
that: CallSuperConstructor,
|
|
701
|
+
) -> stringify.Entity:
|
|
702
|
+
result = stringify.Entity(
|
|
703
|
+
name=that.__class__.__name__,
|
|
704
|
+
properties=[
|
|
705
|
+
stringify.Property("super_name", that.super_name),
|
|
706
|
+
],
|
|
707
|
+
)
|
|
708
|
+
|
|
709
|
+
return result
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
_DISPATCH = {
|
|
713
|
+
EmptyList: _stringify_empty_list,
|
|
714
|
+
DefaultEnumLiteral: _stringify_default_enum_literal,
|
|
715
|
+
AssignArgument: _stringify_assign_argument,
|
|
716
|
+
CallSuperConstructor: _stringify_call_super_constructor,
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
stringify.assert_dispatch_exhaustive(dispatch=_DISPATCH, dumpable=Dumpable)
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
def _stringify(that: Optional[Dumpable]) -> Optional[stringify.Entity]:
|
|
723
|
+
"""Dispatch to the correct ``_stringify_*`` method."""
|
|
724
|
+
if that is None:
|
|
725
|
+
return None
|
|
726
|
+
|
|
727
|
+
stringify_func = _DISPATCH.get(that.__class__, None)
|
|
728
|
+
if stringify_func is None:
|
|
729
|
+
raise AssertionError(
|
|
730
|
+
f"No stringify function could be found for the class {that.__class__}"
|
|
731
|
+
)
|
|
732
|
+
|
|
733
|
+
stringified = stringify_func(that) # type: ignore
|
|
734
|
+
assert isinstance(stringified, stringify.Entity)
|
|
735
|
+
stringify.assert_compares_against_dict(stringified, that)
|
|
736
|
+
|
|
737
|
+
return stringified
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
def dump(that: Optional[Dumpable]) -> str:
|
|
741
|
+
"""Produce a string representation of the ``dumpable`` for testing or debugging."""
|
|
742
|
+
if that is None:
|
|
743
|
+
return repr(None)
|
|
744
|
+
|
|
745
|
+
stringified = _stringify(that)
|
|
746
|
+
return stringify.dump(stringified)
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
DefaultUnion = Union[EmptyList, DefaultEnumLiteral]
|
|
750
|
+
assert_union_of_descendants_exhaustive(union=DefaultUnion, base_class=Default)
|