interlis2py 0.1.0__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.
- ili2py/__init__.py +3 -0
- ili2py/_version.py +24 -0
- ili2py/cli.py +229 -0
- ili2py/interfaces/__init__.py +0 -0
- ili2py/interfaces/interlis/__init__.py +0 -0
- ili2py/interfaces/interlis/interlis_23/__init__.py +36 -0
- ili2py/interfaces/interlis/interlis_23/generator.py +146 -0
- ili2py/interfaces/interlis/interlis_24/__init__.py +37 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/README.md +21 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/__init__.py +0 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/__init__.py +815 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/actual_argument_type.py +630 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/actual_argument_type_formal_argument.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/actual_argument_type_object_classes.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/allowed_in_basket.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/allowed_in_basket_type.py +33 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/allowed_in_basket_type_class_in_basket.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/allowed_in_basket_type_of_data_unit.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/any_oidtype.py +12 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/any_oidtype_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/aref_of.py +12 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/aref_of_type.py +9 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/aref_restriction.py +12 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/aref_restriction_type.py +32 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/aref_restriction_type_aref.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/aref_restriction_type_type.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/argument.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/argument_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/argument_type_1.py +62 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/argument_type_function.py +37 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/argument_type_type_1.py +9 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/assoc_acc.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/assoc_acc_origin.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/assoc_acc_origin_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/assoc_acc_target.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/assoc_acc_target_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/assoc_acc_type.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/assoc_acc_type_assoc_acc.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/assoc_acc_type_class.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/assoc_role.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/assoc_role_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attr_or_param.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attr_or_param_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attr_or_param_type_1.py +88 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attr_or_param_type_attr_parent.py +37 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attr_or_param_type_derivates.py +116 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attr_or_param_type_param_parent.py +37 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attr_or_param_type_type_1.py +9 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attribute_const.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attribute_const_type.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attribute_const_type_attribute.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attribute_ref_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attribute_ref_type_type.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/attribute_ref_type_type_of.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/axis_spec.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/axis_spec_type.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/axis_spec_type_axis.py +27 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/axis_spec_type_coord_type.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/base_class.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/base_class_type.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/base_class_type_base_class.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/base_class_type_crt.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/base_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/base_type_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/base_view_def.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/base_view_def_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/base_view_ref.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/base_view_ref_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/blackbox_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/blackbox_type_type.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/boolean_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/boolean_type_type.py +10 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_attr.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_attr_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_const.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_const_type.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_const_type_class.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_constraint.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_constraint_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_mod.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_param.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_param_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_ref.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_ref_type.py +23 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_ref_type_ref.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_ref_type_type.py +10 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_related_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_related_type_type.py +10 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_restriction.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_restriction_type.py +31 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_restriction_type_class_restriction.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_restriction_type_crtr.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_type.py +74 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_type_existence_constraint.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_type_multiplicity.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_type_oid.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/class_type_view.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/concrete_for_generic.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/concrete_for_generic_type.py +33 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/concrete_for_generic_type_concrete_domain.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/concrete_for_generic_type_generic_def.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/cond_sign_param_assignment.py +13 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/cond_sign_param_assignment_type.py +31 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/cond_sign_param_assignment_type_assignments.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/cond_sign_param_assignment_type_where.py +116 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/constant.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/constant_type.py +28 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/constraint.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/constraint_type.py +28 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/constraint_type_to_class.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/constraint_type_to_domain.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/context.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/context_type.py +10 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/coord_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/coord_type_type.py +38 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/data_unit.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/data_unit_type.py +37 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/data_unit_type_oid.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/dependency.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/dependency_type.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/dependency_type_dependent.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/dependency_type_using.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/derived_assoc.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/derived_assoc_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/doc_text.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/doc_text_translation.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/doc_text_translation_type.py +17 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/doc_text_type.py +25 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/domain_constraint.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/domain_constraint_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/domain_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/domain_type_type.py +28 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/domain_type_type_context.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/drawing_rule.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/drawing_rule_type.py +37 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/drawing_rule_type_class.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/drawing_rule_type_graphic.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/drawing_rule_type_rule.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/enum_assignment_type_max_enum_value.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/enum_assignment_type_min_enum_value.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/enum_mapping_type_enum_value.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/enum_node.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/enum_node_type.py +28 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/enum_node_type_enum_type.py +37 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/enum_node_type_parent_node.py +37 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/enum_tree_value_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/enum_tree_value_type_type.py +20 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/enum_tree_value_type_type_et.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/enum_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/enum_type_type.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/existence_constraint.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/existence_constraint_type.py +20 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/existence_constraint_type_attr.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/existence_def.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/existence_def_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/explicit_assoc_acc.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/explicit_assoc_acc_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/explicit_assoc_access.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/explicit_assoc_access_type.py +44 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/explicit_assoc_access_type_assoc_acc_of.py +37 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/explicit_assoc_access_type_origin_role.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/explicit_assoc_access_type_target_role.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/expression.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/expression_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/extendable_me.py +12 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/extendable_metype.py +49 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/extendable_metype_super.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/factor.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/factor_type.py +10 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/formal_argument.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/formal_argument_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/formatted_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/formatted_type_type.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/formatted_type_type_struct.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/function_call_type_function.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/function_def.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/function_def_type.py +28 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/function_def_type_result_type.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/generic_def.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/generic_def_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/graphic.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/graphic_base.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/graphic_base_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/graphic_rule.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/graphic_rule_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/graphic_type.py +28 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/graphic_type_base.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/graphic_type_where.py +116 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/ili1_format.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/ili1_format_type.py +96 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/ili1_transfer_element.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/ili1_transfer_element_type.py +35 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/ili1_transfer_element_type_ili1_ref_attr.py +27 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/ili1_transfer_element_type_ili1_transfer_class.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/import_mod.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/import_type.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/import_type_imported_p.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/import_type_importing_p.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/inheritance.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/inheritance_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_attr.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_attr_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_coord.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_coord_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_form.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_form_structure.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_form_structure_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_form_type.py +20 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_form_type_structure.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_type_type.py +53 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_type_type_coord_type.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/line_type_type_lastructure.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/lines_form.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/lines_form_type.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/lines_form_type_line_form.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/lines_form_type_line_type.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/local_ftype.py +12 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/local_ftype_type.py +9 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/local_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/local_type_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_attribute.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_attribute_type.py +46 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_attribute_type_meta_element.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_attributes.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_attributes_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_basket_def.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_basket_def_type.py +31 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_basket_def_type_meta_data_topic.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_basket_members.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_basket_members_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_data_unit.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_data_unit_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_element.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_element_type.py +48 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_element_type_documentation.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_element_type_element_in_package.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_object_class.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_object_class_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_object_def.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_object_def_type.py +40 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_object_def_type_class.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/meta_object_def_type_meta_basket_def.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/metranslation.py +12 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/metranslation_type.py +41 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/metranslation_type_of.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/metranslation_type_translated_doc.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/model.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/model_data.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/model_data_basket_oid.py +12 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/model_data_basket_oidtype.py +9 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/model_data_type.py +455 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/model_translation.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/model_translation_type.py +33 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/model_type.py +101 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/model_type_ili1_format.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/multi_value.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/multi_value_type.py +28 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/multi_value_type_multiplicity.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/multiplicity.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/multiplicity_type.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/num_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/num_type_type.py +60 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/num_type_type_ref_sys.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/num_type_type_unit.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/num_unit.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/num_unit_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/nums_ref_sys.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/nums_ref_sys_type.py +18 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/object_oid.py +12 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/object_oidtype.py +9 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/object_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/object_type_type.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/package.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/package_elements.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/package_elements_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/package_type.py +10 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/path_el.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/path_el_type.py +44 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/path_el_type_ref.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/path_or_insp_factor.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/path_or_insp_factor_type.py +32 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/path_or_insp_factor_type_inspection.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/path_or_insp_factor_type_path_els.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/reference_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/reference_type_type.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/renamed_base_view.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/renamed_base_view_type.py +39 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/renamed_base_view_type_base_view.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/renamed_base_view_type_view.py +37 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/result_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/result_type_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/role.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/role_type.py +64 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/role_type_association.py +37 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/role_type_derivates.py +116 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/role_type_multiplicity.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/runtime_param_ref.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/runtime_param_ref_type.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/runtime_param_ref_type_runtime_param.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/set_constraint.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/set_constraint_type.py +28 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/set_constraint_type_constraint.py +116 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/set_constraint_type_where.py +116 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/sign_class.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/sign_class_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/sign_param_assignment.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/sign_param_assignment_type.py +32 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/sign_param_assignment_type_assignment.py +116 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/sign_param_assignment_type_param.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/simple_constraint.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/simple_constraint_type.py +42 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/simple_constraint_type_logical_expression.py +116 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/struct_of_format.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/struct_of_format_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/sub_model.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/sub_model_type.py +10 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/sub_node.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/sub_node_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/text_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/text_type_type.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/top_node.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/top_node_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/transfer_element.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/transfer_element_type.py +33 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/transfer_element_type_transfer_class.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/transfer_element_type_transfer_element.py +27 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/translation.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/translation_type.py +36 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/translation_type_translations.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/tree_value_type_of.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/tree_value_type_of_type.py +8 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/type_mod.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/type_related_type.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/type_related_type_type.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/type_related_type_type_base_type.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/type_restriction.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/type_restriction_type.py +31 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/type_restriction_type_trtr.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/type_restriction_type_type_restriction.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/type_type.py +28 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/type_type_lftparent.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/type_type_ltparent.py +29 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/unique_constraint.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/unique_constraint_type.py +40 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/unique_constraint_type_unique_def.py +22 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/unique_constraint_type_where.py +116 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/unit.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/unit_function.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/unit_function_type.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/unit_ref.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/unit_ref_type.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/unit_ref_type_unit.py +19 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/unit_type.py +28 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/unit_type_definition.py +116 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/view.py +11 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/view_type.py +46 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/view_type_formation_parameter.py +116 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta/ilismeta16_2022_10_10/view_type_where.py +116 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/README.md +6 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/__init__.py +45 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/helper.py +65 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/__init__.py +0 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/abstract_element.py +85 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/constraints.py +47 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/__init__.py +0 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/extendable_me.py +102 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/type/__init__.py +0 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/type/domain_type/__init__.py +0 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/type/domain_type/class_related_type/__init__.py +0 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/type/domain_type/class_related_type/class_related_type.py +26 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/type/domain_type/class_related_type/role.py +56 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/type/domain_type/domain_type.py +171 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/type/expression/__init__.py +0 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/type/expression/expression.py +52 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/type/expression/factor/__init__.py +0 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/type/expression/factor/factor.py +46 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/extendable_me/type/type_class.py +77 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/line_form.py +39 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/meta_element.py +47 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/model_data.py +132 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/package/__init__.py +0 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/package/package.py +99 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/path_elements.py +51 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/references.py +57 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_data/serialization_elements.py +81 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/model_translation/__init__.py +0 -0
- ili2py/interfaces/interlis/interlis_24/ilismeta16/shared.py +5 -0
- ili2py/mappers/__init__.py +0 -0
- ili2py/mappers/helpers.py +1018 -0
- ili2py/mappers/internal/__init__.py +0 -0
- ili2py/mappers/internal/ilismeta16/__init__.py +0 -0
- ili2py/mappers/internal/ilismeta16/domain.py +29 -0
- ili2py/mappers/internal/ilismeta16/model_data/__init__.py +0 -0
- ili2py/mappers/internal/ilismeta16/model_data/definitions.py +401 -0
- ili2py/mappers/internal/ilismeta16/model_data/domain.py +31 -0
- ili2py/mappers/internal/ilismeta16/model_data/types.py +94 -0
- ili2py/mappers/internal/ilismeta16/model_data/units.py +49 -0
- ili2py/py.typed +0 -0
- ili2py/readers/__init__.py +0 -0
- ili2py/readers/interlis_23/__init__.py +0 -0
- ili2py/readers/interlis_23/xtf/__init__.py +0 -0
- ili2py/readers/interlis_23/xtf/xsdata.py +38 -0
- ili2py/readers/interlis_24/__init__.py +0 -0
- ili2py/readers/interlis_24/ilismeta16/__init__.py +0 -0
- ili2py/readers/interlis_24/ilismeta16/xsdata.py +40 -0
- ili2py/readers/interlis_24/xtf/__init__.py +0 -0
- ili2py/scripts/__init__.py +0 -0
- ili2py/scripts/config.py +21 -0
- ili2py/scripts/generate_docs_diagrams.py +177 -0
- ili2py/scripts/generate_mermaid_diagrams.py +118 -0
- ili2py/scripts/generate_plantuml_diagrams.py +156 -0
- ili2py/scripts/generate_test_output.py +632 -0
- ili2py/writers/__init__.py +0 -0
- ili2py/writers/diagram/__init__.py +33 -0
- ili2py/writers/diagram/interlis/__init__.py +115 -0
- ili2py/writers/diagram/interlis/templates/dot/class.jinja2 +34 -0
- ili2py/writers/diagram/interlis/templates/dot/classes.jinja2 +4 -0
- ili2py/writers/diagram/interlis/templates/dot/dot.jinja2 +48 -0
- ili2py/writers/diagram/interlis/templates/mermaid/mermaid.jinja2 +69 -0
- ili2py/writers/diagram/interlis/templates/plantuml/plantuml.jinja2 +62 -0
- ili2py/writers/diagram/interlis/templates/plantuml_role_members/plantuml_role_members.jinja2 +78 -0
- ili2py/writers/diagram/interlis/uml.py +353 -0
- ili2py/writers/helpers.py +36 -0
- ili2py/writers/py/__init__.py +0 -0
- ili2py/writers/py/constraints.py +183 -0
- ili2py/writers/py/interlis23/templates/classes.jinja2 +218 -0
- ili2py/writers/py/interlis23/templates/convertable_types.jinja2 +50 -0
- ili2py/writers/py/interlis23/templates/coord_types.jinja2 +126 -0
- ili2py/writers/py/interlis23/templates/domain_types.jinja2 +26 -0
- ili2py/writers/py/interlis23/templates/enumerations.jinja2 +27 -0
- ili2py/writers/py/interlis23/templates/library_init.jinja2 +5 -0
- ili2py/writers/py/interlis23/templates/line_types.jinja2 +162 -0
- ili2py/writers/py/interlis23/templates/module.jinja2 +89 -0
- ili2py/writers/py/interlis23/templates/package_init.jinja2 +56 -0
- ili2py/writers/py/interlis23/templates/references.jinja2 +26 -0
- ili2py/writers/py/interlis23/templates/xtf_opening.jinja2 +126 -0
- ili2py/writers/py/interlis24/templates/classes.jinja2 +225 -0
- ili2py/writers/py/interlis24/templates/convertable_types.jinja2 +50 -0
- ili2py/writers/py/interlis24/templates/coord_types.jinja2 +120 -0
- ili2py/writers/py/interlis24/templates/domain_types.jinja2 +26 -0
- ili2py/writers/py/interlis24/templates/enumerations.jinja2 +27 -0
- ili2py/writers/py/interlis24/templates/library_init.jinja2 +5 -0
- ili2py/writers/py/interlis24/templates/line_type_polyline.jinja2 +31 -0
- ili2py/writers/py/interlis24/templates/line_type_polyline_multi.jinja2 +49 -0
- ili2py/writers/py/interlis24/templates/line_type_segment.jinja2 +27 -0
- ili2py/writers/py/interlis24/templates/line_type_surface.jinja2 +31 -0
- ili2py/writers/py/interlis24/templates/line_type_surface_boundary.jinja2 +40 -0
- ili2py/writers/py/interlis24/templates/line_type_surface_multi.jinja2 +50 -0
- ili2py/writers/py/interlis24/templates/line_types.jinja2 +41 -0
- ili2py/writers/py/interlis24/templates/module.jinja2 +89 -0
- ili2py/writers/py/interlis24/templates/package_init.jinja2 +56 -0
- ili2py/writers/py/interlis24/templates/references.jinja2 +13 -0
- ili2py/writers/py/interlis24/templates/xtf_opening.jinja2 +120 -0
- ili2py/writers/py/python_structure.py +1829 -0
- ili2py/writers/py/render.py +180 -0
- interlis2py-0.1.0.dist-info/METADATA +91 -0
- interlis2py-0.1.0.dist-info/RECORD +462 -0
- interlis2py-0.1.0.dist-info/WHEEL +5 -0
- interlis2py-0.1.0.dist-info/entry_points.txt +2 -0
- interlis2py-0.1.0.dist-info/licenses/LICENSE +661 -0
- interlis2py-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1829 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from abc import ABC
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import Any, Optional
|
|
5
|
+
|
|
6
|
+
from xsdata.formats.dataclass.serializers import DictEncoder
|
|
7
|
+
|
|
8
|
+
from ili2py.interfaces.interlis.interlis_24.ilismeta.ilismeta16_2022_10_10 import (
|
|
9
|
+
ActualArgumentType,
|
|
10
|
+
AttributeConstType,
|
|
11
|
+
AttrOrParam,
|
|
12
|
+
AxisSpec,
|
|
13
|
+
BlackboxType,
|
|
14
|
+
BooleanType,
|
|
15
|
+
ClassConstType,
|
|
16
|
+
ClassRefType,
|
|
17
|
+
CompoundExprType,
|
|
18
|
+
ConstantType,
|
|
19
|
+
DataUnit,
|
|
20
|
+
EnumAssignmentType,
|
|
21
|
+
EnumMappingType,
|
|
22
|
+
EnumNode,
|
|
23
|
+
EnumTreeValueType,
|
|
24
|
+
EnumType,
|
|
25
|
+
ExistenceConstraintType,
|
|
26
|
+
FormattedType,
|
|
27
|
+
FunctionCallType,
|
|
28
|
+
MetaElementType,
|
|
29
|
+
MetaElementTypeDocumentation,
|
|
30
|
+
Model,
|
|
31
|
+
ModelData,
|
|
32
|
+
MultiValue,
|
|
33
|
+
MultiValueType,
|
|
34
|
+
NumType,
|
|
35
|
+
NumTypeType,
|
|
36
|
+
PathOrInspFactorType,
|
|
37
|
+
PathOrInspFactorTypePathEls,
|
|
38
|
+
ReferenceType,
|
|
39
|
+
RuntimeParamRefType,
|
|
40
|
+
SetConstraintType,
|
|
41
|
+
SimpleConstraintType,
|
|
42
|
+
SubModel,
|
|
43
|
+
TextType,
|
|
44
|
+
TypeType,
|
|
45
|
+
UnaryExprType,
|
|
46
|
+
UniqueConstraintType,
|
|
47
|
+
UnitFunctionType,
|
|
48
|
+
UnitRefType,
|
|
49
|
+
)
|
|
50
|
+
from ili2py.interfaces.interlis.interlis_24.ilismeta.ilismeta16_2022_10_10 import (
|
|
51
|
+
Class as ImdClass,
|
|
52
|
+
)
|
|
53
|
+
from ili2py.interfaces.interlis.interlis_24.ilismeta.ilismeta16_2022_10_10 import (
|
|
54
|
+
CoordType as ImdCoordType,
|
|
55
|
+
)
|
|
56
|
+
from ili2py.interfaces.interlis.interlis_24.ilismeta.ilismeta16_2022_10_10 import (
|
|
57
|
+
ExpressionType as ImdExpressionType,
|
|
58
|
+
)
|
|
59
|
+
from ili2py.interfaces.interlis.interlis_24.ilismeta.ilismeta16_2022_10_10 import (
|
|
60
|
+
LineType as ImdLineType,
|
|
61
|
+
)
|
|
62
|
+
from ili2py.interfaces.interlis.interlis_24.ilismeta.ilismeta16_2022_10_10 import (
|
|
63
|
+
MetaAttribute as ImdMetaAttribute,
|
|
64
|
+
)
|
|
65
|
+
from ili2py.interfaces.interlis.interlis_24.ilismeta.ilismeta16_2022_10_10 import (
|
|
66
|
+
Role as ImdRole,
|
|
67
|
+
)
|
|
68
|
+
from ili2py.mappers.helpers import Index, mandatory, mandatory_ref
|
|
69
|
+
from ili2py.writers.py.constraints import (
|
|
70
|
+
ActualArgument,
|
|
71
|
+
AttributeConst,
|
|
72
|
+
ClassConst,
|
|
73
|
+
CompoundExpr,
|
|
74
|
+
Constant,
|
|
75
|
+
EnumAssignment,
|
|
76
|
+
EnumMapping,
|
|
77
|
+
ExistenceConstraint,
|
|
78
|
+
ExpressionType,
|
|
79
|
+
FunctionCall,
|
|
80
|
+
PathEl,
|
|
81
|
+
PathOrInspFactor,
|
|
82
|
+
RuntimeParamRef,
|
|
83
|
+
SetConstraint,
|
|
84
|
+
SimpleConstraint,
|
|
85
|
+
UnaryExpr,
|
|
86
|
+
UniqueConstraint,
|
|
87
|
+
UnitFunction,
|
|
88
|
+
UnitRef,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
base_type_dictionary = {
|
|
92
|
+
"TextType": "str",
|
|
93
|
+
"FormattedType": "str",
|
|
94
|
+
"BlackboxType": "bytes",
|
|
95
|
+
"NumType": "float",
|
|
96
|
+
"BooleanType": "bool",
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# (module path, class name, alias) of an import in the generated code
|
|
100
|
+
type RelatedImport = tuple[str, str | None, str | None]
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@dataclass
|
|
104
|
+
class MetaAttribute:
|
|
105
|
+
name: str
|
|
106
|
+
value: str
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@dataclass
|
|
110
|
+
class Base(ABC):
|
|
111
|
+
# See chapter 2.1.2 Klasse MetaElement in the IlisMeta16 documentation:
|
|
112
|
+
# https://github.com/rudert-geoinformatik/ili2py/blob/master/tests/data/ilismeta16/ili24-metamodel_2022-06-17_d.pdf
|
|
113
|
+
OID_SEPARATOR = "."
|
|
114
|
+
PYTHON_NAME_SEPARATOR = ""
|
|
115
|
+
name: str
|
|
116
|
+
identifier: str
|
|
117
|
+
doc: list[str]
|
|
118
|
+
meta_attributes: list[MetaAttribute]
|
|
119
|
+
|
|
120
|
+
@staticmethod
|
|
121
|
+
def doc_string(documentation: list[MetaElementTypeDocumentation]) -> list[str]:
|
|
122
|
+
"""
|
|
123
|
+
Creates a list of documentation strings.
|
|
124
|
+
Args:
|
|
125
|
+
documentation: The documentation which will be flattened
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
The flattened version of the given documentation.
|
|
129
|
+
"""
|
|
130
|
+
return [mandatory(mandatory(item.doc_text).text) for item in documentation]
|
|
131
|
+
|
|
132
|
+
@staticmethod
|
|
133
|
+
def get_element_of_type_from_list(
|
|
134
|
+
element_type: Any,
|
|
135
|
+
element_list: list[Any],
|
|
136
|
+
kinds: list[str] | None = None,
|
|
137
|
+
) -> list[Any]:
|
|
138
|
+
"""
|
|
139
|
+
Finds the elements which match the desired type.
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
element_type: The type to look for
|
|
143
|
+
element_list: The list which should be scanned for the type.
|
|
144
|
+
kind: Optional match parameter for kind (default: None).
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
The list of elements which match the desired type. Will be empty list if no matches
|
|
148
|
+
were found.
|
|
149
|
+
"""
|
|
150
|
+
matching_elements = []
|
|
151
|
+
for element in element_list:
|
|
152
|
+
if isinstance(element, element_type):
|
|
153
|
+
if kinds is not None:
|
|
154
|
+
if element.kind in kinds:
|
|
155
|
+
matching_elements.append(element)
|
|
156
|
+
else:
|
|
157
|
+
matching_elements.append(element)
|
|
158
|
+
return matching_elements
|
|
159
|
+
|
|
160
|
+
@staticmethod
|
|
161
|
+
def assemble_meta_attributes(index: Index, meta_element_tid: str) -> list[MetaAttribute]:
|
|
162
|
+
meta_attributes = []
|
|
163
|
+
if meta_element_tid in index.metaelement_metaattributes:
|
|
164
|
+
for item in index.metaelement_metaattributes[meta_element_tid]:
|
|
165
|
+
imd_meta_attribute: ImdMetaAttribute = index.index[item]
|
|
166
|
+
meta_attributes.append(
|
|
167
|
+
MetaAttribute(
|
|
168
|
+
name=mandatory(imd_meta_attribute.name),
|
|
169
|
+
value=mandatory(imd_meta_attribute.value),
|
|
170
|
+
)
|
|
171
|
+
)
|
|
172
|
+
return meta_attributes
|
|
173
|
+
|
|
174
|
+
@staticmethod
|
|
175
|
+
def pythonize_oid_global(oid: str) -> str:
|
|
176
|
+
"""
|
|
177
|
+
Central method to create a pythonic name out of the passed oid. It can be used to
|
|
178
|
+
derive IMD wide unique names which are save to be used in python as e.g. class names.
|
|
179
|
+
|
|
180
|
+
The default behaiour is:
|
|
181
|
+
'LocalisationCH_V1.MultilingualText.LocalisedText.TYPE'
|
|
182
|
+
=> 'LocalisationCH_V1MultilingualTextLocalisedTextTYPE'
|
|
183
|
+
Args:
|
|
184
|
+
oid: The OID string which is split by the oid_separator.
|
|
185
|
+
python_separator: The separator which is used to join the pythonic name.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
The pythonized version of the OID.
|
|
189
|
+
"""
|
|
190
|
+
oid_parts = oid.split(Base.OID_SEPARATOR)
|
|
191
|
+
return Base.PYTHON_NAME_SEPARATOR.join(oid_parts)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
@dataclass
|
|
195
|
+
class Attribute(Base):
|
|
196
|
+
"""Represents imd AttrOrParam"""
|
|
197
|
+
|
|
198
|
+
types: list[str]
|
|
199
|
+
type_restrictions: dict = field(default_factory=dict)
|
|
200
|
+
enumeration: Optional["Enumeration"] = field(default=None)
|
|
201
|
+
line_type: Optional["LineType"] = field(default=None)
|
|
202
|
+
type_related_type_class: Optional["Class"] = field(default=None)
|
|
203
|
+
reference_targets: list[str] = field(default_factory=list)
|
|
204
|
+
is_list_type: bool = field(default=False)
|
|
205
|
+
geometric: bool = field(default=False)
|
|
206
|
+
geometric_multi: bool = field(default=False)
|
|
207
|
+
geometric_is_point_like: bool = field(default=False)
|
|
208
|
+
geometric_is_line_like: bool = field(default=False)
|
|
209
|
+
geometric_is_polygon_like: bool = field(default=False)
|
|
210
|
+
type_related_imports: list[RelatedImport] = field(default_factory=list)
|
|
211
|
+
namespace_package: str | None = field(default=None)
|
|
212
|
+
kind: str | None = field(default=None)
|
|
213
|
+
|
|
214
|
+
@staticmethod
|
|
215
|
+
def check_float_kind(representation: str | None) -> bool:
|
|
216
|
+
"""
|
|
217
|
+
Checks if a passed string of IMD16 number kinds can be interpreted as float.
|
|
218
|
+
|
|
219
|
+
Args:
|
|
220
|
+
representation: The numeric representation (e.g. 1000.00 or 1000 or -1000.000)
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
True if it can be interpreted as float kind, False if not.
|
|
224
|
+
"""
|
|
225
|
+
if representation:
|
|
226
|
+
return len(representation.split(".")) == 2
|
|
227
|
+
else:
|
|
228
|
+
return False
|
|
229
|
+
|
|
230
|
+
@staticmethod
|
|
231
|
+
def check_type_float(type_definition: NumType) -> bool:
|
|
232
|
+
return Attribute.check_float_kind(type_definition.min) or Attribute.check_float_kind(
|
|
233
|
+
type_definition.max
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
@staticmethod
|
|
237
|
+
def handle_type_trail(
|
|
238
|
+
imd_type: (
|
|
239
|
+
TextType
|
|
240
|
+
| FormattedType
|
|
241
|
+
| BlackboxType
|
|
242
|
+
| NumType
|
|
243
|
+
| BooleanType
|
|
244
|
+
| MultiValue
|
|
245
|
+
| EnumType
|
|
246
|
+
| ImdCoordType
|
|
247
|
+
| ImdLineType
|
|
248
|
+
| TypeType
|
|
249
|
+
| ClassRefType
|
|
250
|
+
| ReferenceType
|
|
251
|
+
),
|
|
252
|
+
index: Index,
|
|
253
|
+
) -> tuple[str, bool]:
|
|
254
|
+
"""
|
|
255
|
+
This method handles type resolution. When possible it returns a simple type name of
|
|
256
|
+
Python (e.g. str, int, bool, etc.). When it is not possible to return a simple type,
|
|
257
|
+
the OID of the linked type will be returned.
|
|
258
|
+
|
|
259
|
+
Args:
|
|
260
|
+
imd_type: The type which should be looked up
|
|
261
|
+
index: The index which can be used to look up the type and maybe follow the path
|
|
262
|
+
till the acutal type is found.
|
|
263
|
+
|
|
264
|
+
Returns:
|
|
265
|
+
The string representing the type and flag if returned string is a OID or not (might
|
|
266
|
+
be looked up in index).
|
|
267
|
+
"""
|
|
268
|
+
if isinstance(imd_type, (TextType, FormattedType)):
|
|
269
|
+
return "str", False
|
|
270
|
+
elif isinstance(imd_type, ClassRefType):
|
|
271
|
+
if imd_type.ref:
|
|
272
|
+
return mandatory(imd_type.ref.ref), True
|
|
273
|
+
else:
|
|
274
|
+
return "Any", False
|
|
275
|
+
elif isinstance(imd_type, BlackboxType):
|
|
276
|
+
kind = mandatory(imd_type.kind).upper()
|
|
277
|
+
if kind == "BINARY":
|
|
278
|
+
return "BinBlBoxType", False
|
|
279
|
+
elif kind == "XML":
|
|
280
|
+
return "XmlBlBoxType", False
|
|
281
|
+
else:
|
|
282
|
+
logging.debug(f"Binary type was not handled correctly {imd_type}")
|
|
283
|
+
return "str", False
|
|
284
|
+
elif isinstance(imd_type, NumType):
|
|
285
|
+
float_kind = Attribute.check_type_float(imd_type)
|
|
286
|
+
if float_kind:
|
|
287
|
+
return "float", False
|
|
288
|
+
else:
|
|
289
|
+
return "int", False
|
|
290
|
+
elif isinstance(imd_type, BooleanType):
|
|
291
|
+
return "bool", False
|
|
292
|
+
elif isinstance(imd_type, (ImdCoordType, ImdLineType)):
|
|
293
|
+
if imd_type.name == "TYPE":
|
|
294
|
+
if imd_type.super:
|
|
295
|
+
return mandatory(imd_type.super.ref), True
|
|
296
|
+
else:
|
|
297
|
+
return mandatory(imd_type.tid), True
|
|
298
|
+
else:
|
|
299
|
+
return mandatory(imd_type.tid), True
|
|
300
|
+
elif isinstance(imd_type, MultiValue):
|
|
301
|
+
base_type_ref = mandatory_ref(imd_type.base_type)
|
|
302
|
+
if isinstance(index.index[base_type_ref], ImdClass):
|
|
303
|
+
# we directly return the original base type ref here, this means its the oid of
|
|
304
|
+
# a structure class
|
|
305
|
+
# we expect that class to exist in the right place (see class.from_imd)
|
|
306
|
+
return base_type_ref, True
|
|
307
|
+
else:
|
|
308
|
+
return mandatory(imd_type.tid), True
|
|
309
|
+
elif isinstance(imd_type, (EnumType, EnumTreeValueType)):
|
|
310
|
+
return mandatory(imd_type.tid), True
|
|
311
|
+
elif isinstance(imd_type, ReferenceType):
|
|
312
|
+
return "Ref", False
|
|
313
|
+
else:
|
|
314
|
+
logging.debug(
|
|
315
|
+
"Type was not handled correctly for Python-Class-Generation preparation: "
|
|
316
|
+
f"{imd_type}"
|
|
317
|
+
)
|
|
318
|
+
return "UNKNOWN", False
|
|
319
|
+
|
|
320
|
+
@staticmethod
|
|
321
|
+
def derive_precision(representation: str) -> int:
|
|
322
|
+
"""
|
|
323
|
+
Derives the precision of a float string representation (e.g. "1000.00" -> 2).
|
|
324
|
+
Args:
|
|
325
|
+
representation: The string representing a float.
|
|
326
|
+
|
|
327
|
+
Returns:
|
|
328
|
+
The preciscion of the float.
|
|
329
|
+
"""
|
|
330
|
+
return len(representation.split(".")[1])
|
|
331
|
+
|
|
332
|
+
@classmethod
|
|
333
|
+
def construct_type_restrictions(
|
|
334
|
+
cls,
|
|
335
|
+
imd_type: (
|
|
336
|
+
TextType
|
|
337
|
+
| FormattedType
|
|
338
|
+
| BlackboxType
|
|
339
|
+
| NumType
|
|
340
|
+
| BooleanType
|
|
341
|
+
| MultiValue
|
|
342
|
+
| EnumType
|
|
343
|
+
| ImdCoordType
|
|
344
|
+
| ImdRole
|
|
345
|
+
),
|
|
346
|
+
type_related_type: bool = False,
|
|
347
|
+
) -> dict:
|
|
348
|
+
type_restrictions: dict[str, Any] = {
|
|
349
|
+
"mandatory": imd_type.mandatory,
|
|
350
|
+
"kind": None,
|
|
351
|
+
"format": None,
|
|
352
|
+
"unit": None,
|
|
353
|
+
"ref_sys": None,
|
|
354
|
+
"clockwise": None,
|
|
355
|
+
"circular": None,
|
|
356
|
+
"abstract": imd_type.abstract,
|
|
357
|
+
"final": imd_type.final,
|
|
358
|
+
"generic": imd_type.generic,
|
|
359
|
+
"super": imd_type.super.ref if imd_type.super else imd_type.super,
|
|
360
|
+
"type_related_type": type_related_type,
|
|
361
|
+
}
|
|
362
|
+
if imd_type.mandatory:
|
|
363
|
+
type_restrictions["multiplicity"] = {"min": 1, "max": 1}
|
|
364
|
+
else:
|
|
365
|
+
type_restrictions["multiplicity"] = {"min": 0, "max": 1}
|
|
366
|
+
if isinstance(imd_type, TextType):
|
|
367
|
+
if imd_type.max_length is not None:
|
|
368
|
+
type_restrictions.update(**{"max_length": imd_type.max_length})
|
|
369
|
+
elif isinstance(imd_type, NumTypeType):
|
|
370
|
+
if imd_type.unit:
|
|
371
|
+
type_restrictions["unit"] = imd_type.unit.ref
|
|
372
|
+
type_restrictions["circular"] = imd_type.circular
|
|
373
|
+
type_restrictions["clockwise"] = imd_type.clockwise
|
|
374
|
+
if imd_type.ref_sys:
|
|
375
|
+
type_restrictions["ref_sys"] = imd_type.ref_sys.ref
|
|
376
|
+
float_kind = Attribute.check_float_kind(
|
|
377
|
+
imd_type.min
|
|
378
|
+
) or Attribute.check_float_kind(imd_type.max)
|
|
379
|
+
if isinstance(imd_type, NumType):
|
|
380
|
+
if imd_type.min is not None:
|
|
381
|
+
if float_kind:
|
|
382
|
+
min_value = float(imd_type.min)
|
|
383
|
+
type_restrictions["precision"] = Attribute.derive_precision(
|
|
384
|
+
imd_type.min
|
|
385
|
+
)
|
|
386
|
+
else:
|
|
387
|
+
min_value = int(imd_type.min)
|
|
388
|
+
type_restrictions["min"] = min_value
|
|
389
|
+
if imd_type.max is not None:
|
|
390
|
+
if float_kind:
|
|
391
|
+
max_value = float(imd_type.max)
|
|
392
|
+
max_precision = Attribute.derive_precision(imd_type.max)
|
|
393
|
+
if max_precision != type_restrictions["precision"]:
|
|
394
|
+
logging.debug(f"NumType precision was not as expected: {imd_type}")
|
|
395
|
+
else:
|
|
396
|
+
max_value = int(imd_type.max)
|
|
397
|
+
type_restrictions["max"] = max_value
|
|
398
|
+
elif isinstance(imd_type, FormattedType):
|
|
399
|
+
type_restrictions["format"] = f'"{imd_type.format}"'
|
|
400
|
+
type_restrictions["struct"] = mandatory(imd_type.struct).ref
|
|
401
|
+
type_restrictions["min"] = imd_type.min
|
|
402
|
+
type_restrictions["max"] = imd_type.max
|
|
403
|
+
|
|
404
|
+
else:
|
|
405
|
+
logging.debug(
|
|
406
|
+
f"SubType of NumTypeType was not handled by range assertions: {imd_type}"
|
|
407
|
+
)
|
|
408
|
+
elif isinstance(imd_type, (ImdRole, MultiValue)):
|
|
409
|
+
# Multiplicity is optional in IlisMeta16, but ili2c always writes it
|
|
410
|
+
if imd_type.multiplicity and imd_type.multiplicity.multiplicity:
|
|
411
|
+
type_restrictions["multiplicity"] = {
|
|
412
|
+
"min": imd_type.multiplicity.multiplicity.min,
|
|
413
|
+
"max": imd_type.multiplicity.multiplicity.max,
|
|
414
|
+
}
|
|
415
|
+
else:
|
|
416
|
+
logging.warning(f"{imd_type.tid} has no multiplicity, this is unusual")
|
|
417
|
+
if isinstance(imd_type, ImdRole):
|
|
418
|
+
type_restrictions["association_strongness"] = imd_type.strongness
|
|
419
|
+
elif isinstance(imd_type, BlackboxType):
|
|
420
|
+
type_restrictions["kind"] = imd_type.kind
|
|
421
|
+
else:
|
|
422
|
+
logging.debug(f"Type was not handled by range assertions: {imd_type}")
|
|
423
|
+
return type_restrictions
|
|
424
|
+
|
|
425
|
+
@staticmethod
|
|
426
|
+
def handle_local_types(
|
|
427
|
+
index, resolved_type_name, referenced_type, attr_or_param, referenced_class
|
|
428
|
+
):
|
|
429
|
+
local_type = None
|
|
430
|
+
resolved_type = index.index.get(resolved_type_name)
|
|
431
|
+
if not resolved_type:
|
|
432
|
+
# type name is already a type which is not part of original imd tree, we
|
|
433
|
+
# manipulated it in previous steps and assume here, that we can savely use it
|
|
434
|
+
return resolved_type_name, local_type
|
|
435
|
+
if isinstance(referenced_type, EnumType) and referenced_type.name == "TYPE":
|
|
436
|
+
if referenced_type.name == resolved_type.name:
|
|
437
|
+
class_name = f"{referenced_class.name}{attr_or_param.name}Enum"
|
|
438
|
+
final_type_name = class_name
|
|
439
|
+
local_type = Enumeration.from_imd(referenced_type, index)
|
|
440
|
+
local_type.name = class_name
|
|
441
|
+
else:
|
|
442
|
+
final_type_name = resolved_type_name
|
|
443
|
+
elif isinstance(referenced_type, ImdLineType) and referenced_type.name == "TYPE":
|
|
444
|
+
if referenced_type.name == resolved_type.name:
|
|
445
|
+
class_name = f"{referenced_class.name}{attr_or_param.name}LineType"
|
|
446
|
+
final_type_name = class_name
|
|
447
|
+
local_type = LineType.from_imd(referenced_type, index)
|
|
448
|
+
local_type.name = class_name
|
|
449
|
+
else:
|
|
450
|
+
final_type_name = resolved_type_name
|
|
451
|
+
elif isinstance(referenced_type, MultiValueType) and referenced_type.name in [
|
|
452
|
+
"TYPE",
|
|
453
|
+
"MVT",
|
|
454
|
+
]:
|
|
455
|
+
multi_value_base_type = index.index[referenced_type.base_type.ref]
|
|
456
|
+
imports = []
|
|
457
|
+
if referenced_type.name == "MVT":
|
|
458
|
+
multi_value_base_type_name, is_oid = Attribute.handle_type_trail(
|
|
459
|
+
multi_value_base_type, index
|
|
460
|
+
)
|
|
461
|
+
if is_oid:
|
|
462
|
+
# the multi field is not a simple type but links to a complex one
|
|
463
|
+
multi_value_base_type_name, multi_value_base_type_import = (
|
|
464
|
+
Attribute.decide_type_reference(
|
|
465
|
+
referenced_class, multi_value_base_type.tid, index
|
|
466
|
+
)
|
|
467
|
+
)
|
|
468
|
+
if multi_value_base_type_import:
|
|
469
|
+
imports.append(multi_value_base_type_import)
|
|
470
|
+
type_restrictions = Attribute.construct_type_restrictions(
|
|
471
|
+
multi_value_base_type
|
|
472
|
+
)
|
|
473
|
+
model_name = Attribute.get_model_name_from_type(referenced_type, index)
|
|
474
|
+
list_type = Attribute.decide_list_type(multi_value_base_type)
|
|
475
|
+
else:
|
|
476
|
+
multi_value_base_type_name, multi_value_base_type_import = (
|
|
477
|
+
Attribute.decide_type_reference(
|
|
478
|
+
referenced_class, multi_value_base_type.tid, index
|
|
479
|
+
)
|
|
480
|
+
)
|
|
481
|
+
if multi_value_base_type_import:
|
|
482
|
+
imports.append(multi_value_base_type_import)
|
|
483
|
+
type_restrictions = {"type_related_type": True}
|
|
484
|
+
model_name = Attribute.get_model_name_from_type(multi_value_base_type, index)
|
|
485
|
+
list_type = Attribute.decide_list_type(referenced_type)
|
|
486
|
+
local_type = Class(
|
|
487
|
+
name=f"{referenced_class.name}{attr_or_param.name}Struct",
|
|
488
|
+
identifier=referenced_type.tid,
|
|
489
|
+
doc=[
|
|
490
|
+
"This Class is a HOP-Class to correctly parse XTF. It was inserted by "
|
|
491
|
+
"ili2py"
|
|
492
|
+
],
|
|
493
|
+
meta_attributes=Attribute.assemble_meta_attributes(index, referenced_type.tid),
|
|
494
|
+
super_class=None,
|
|
495
|
+
attributes=[
|
|
496
|
+
Attribute(
|
|
497
|
+
name="struct_content",
|
|
498
|
+
identifier=f"ili2py.{multi_value_base_type.tid}",
|
|
499
|
+
doc=["This attribute is a HOP-Type to correctly parse XTF."],
|
|
500
|
+
meta_attributes=[],
|
|
501
|
+
types=[multi_value_base_type_name],
|
|
502
|
+
type_restrictions=type_restrictions,
|
|
503
|
+
enumeration=None,
|
|
504
|
+
line_type=None,
|
|
505
|
+
type_related_type_class=None,
|
|
506
|
+
is_list_type=list_type,
|
|
507
|
+
namespace_package=model_name,
|
|
508
|
+
kind=referenced_type.name,
|
|
509
|
+
)
|
|
510
|
+
],
|
|
511
|
+
abstract=False,
|
|
512
|
+
related_class_imports=imports,
|
|
513
|
+
)
|
|
514
|
+
final_type_name = local_type.name
|
|
515
|
+
else:
|
|
516
|
+
final_type_name = resolved_type_name
|
|
517
|
+
return final_type_name, local_type
|
|
518
|
+
|
|
519
|
+
@staticmethod
|
|
520
|
+
def decide_list_type(imd_type_object: MultiValueType):
|
|
521
|
+
list_type = False
|
|
522
|
+
if isinstance(imd_type_object, MultiValueType):
|
|
523
|
+
# we act only if passed type was really a candidate to be a list type
|
|
524
|
+
if imd_type_object.multiplicity:
|
|
525
|
+
if imd_type_object.multiplicity.multiplicity:
|
|
526
|
+
if (
|
|
527
|
+
imd_type_object.multiplicity.multiplicity.max is None
|
|
528
|
+
or imd_type_object.multiplicity.multiplicity.max > 1
|
|
529
|
+
):
|
|
530
|
+
list_type = True
|
|
531
|
+
else:
|
|
532
|
+
logging.warning(
|
|
533
|
+
"MultiValueType had multiplicity.multiplicity => None, this is "
|
|
534
|
+
f"unusual: {imd_type_object}"
|
|
535
|
+
)
|
|
536
|
+
else:
|
|
537
|
+
logging.warning(
|
|
538
|
+
"MultiValueType had multiplicity => None, this is unusual: "
|
|
539
|
+
f"{imd_type_object}"
|
|
540
|
+
)
|
|
541
|
+
return list_type
|
|
542
|
+
|
|
543
|
+
@staticmethod
|
|
544
|
+
def get_referenced_class(imd_attr_or_param: AttrOrParam, index: Index) -> ImdClass:
|
|
545
|
+
if imd_attr_or_param.attr_parent:
|
|
546
|
+
referenced_class = index.index[imd_attr_or_param.attr_parent.ref]
|
|
547
|
+
else:
|
|
548
|
+
# an AttrOrParam is either a ClassAttribute or a ClassParameter
|
|
549
|
+
referenced_class = index.index[mandatory_ref(imd_attr_or_param.param_parent)]
|
|
550
|
+
return referenced_class
|
|
551
|
+
|
|
552
|
+
@staticmethod
|
|
553
|
+
def get_class_location(
|
|
554
|
+
class_definition: ImdClass, index: Index
|
|
555
|
+
) -> tuple[Model, SubModel | None]:
|
|
556
|
+
# classes are always defined in a model or topic
|
|
557
|
+
package = index.index[mandatory_ref(class_definition.element_in_package)]
|
|
558
|
+
sub_model = None
|
|
559
|
+
if isinstance(package, SubModel):
|
|
560
|
+
sub_model = package
|
|
561
|
+
model = index.index[mandatory_ref(package.element_in_package)]
|
|
562
|
+
else:
|
|
563
|
+
model = package
|
|
564
|
+
return model, sub_model
|
|
565
|
+
|
|
566
|
+
@staticmethod
|
|
567
|
+
def attribute_name(attribute: AttrOrParam):
|
|
568
|
+
return mandatory(attribute.name).lower()
|
|
569
|
+
|
|
570
|
+
@classmethod
|
|
571
|
+
def from_imd(
|
|
572
|
+
cls,
|
|
573
|
+
imd_attr_or_param: AttrOrParam,
|
|
574
|
+
imd_model_data: ModelData,
|
|
575
|
+
index: Index,
|
|
576
|
+
):
|
|
577
|
+
tid = mandatory(imd_attr_or_param.tid)
|
|
578
|
+
referenced_type = index.index[mandatory_ref(imd_attr_or_param.type_value)]
|
|
579
|
+
referenced_class = Attribute.get_referenced_class(imd_attr_or_param, index)
|
|
580
|
+
mapped_type, is_oid = cls.handle_type_trail(referenced_type, index)
|
|
581
|
+
meta_attributes = cls.assemble_meta_attributes(index, tid)
|
|
582
|
+
final_type_name, local_type = Attribute.handle_local_types(
|
|
583
|
+
index, mapped_type, referenced_type, imd_attr_or_param, referenced_class
|
|
584
|
+
)
|
|
585
|
+
type_related_imports: list[RelatedImport] = []
|
|
586
|
+
if is_oid and not local_type:
|
|
587
|
+
decided_type_name, type_related_import = Attribute.decide_type_reference(
|
|
588
|
+
referenced_class, final_type_name, index
|
|
589
|
+
)
|
|
590
|
+
if decided_type_name:
|
|
591
|
+
final_type_name = decided_type_name
|
|
592
|
+
if type_related_import:
|
|
593
|
+
type_related_imports.append(type_related_import)
|
|
594
|
+
return cls(
|
|
595
|
+
identifier=tid,
|
|
596
|
+
name=mandatory(imd_attr_or_param.name),
|
|
597
|
+
types=[final_type_name],
|
|
598
|
+
doc=cls.doc_string(imd_attr_or_param.documentation),
|
|
599
|
+
type_restrictions=cls.construct_type_restrictions(referenced_type),
|
|
600
|
+
meta_attributes=meta_attributes,
|
|
601
|
+
enumeration=local_type if isinstance(local_type, Enumeration) else None,
|
|
602
|
+
line_type=local_type if isinstance(local_type, LineType) else None,
|
|
603
|
+
type_related_type_class=local_type if isinstance(local_type, Class) else None,
|
|
604
|
+
is_list_type=Attribute.decide_list_type(referenced_type),
|
|
605
|
+
geometric=tid in index.geometric_attributes,
|
|
606
|
+
geometric_multi=tid in index.geometric_attributes_multi,
|
|
607
|
+
geometric_is_point_like=tid in index.geometric_attributes_point_like,
|
|
608
|
+
geometric_is_line_like=tid in index.geometric_attributes_line_like,
|
|
609
|
+
geometric_is_polygon_like=tid in index.geometric_attributes_polygon_like,
|
|
610
|
+
type_related_imports=type_related_imports,
|
|
611
|
+
namespace_package=Attribute.get_last_super_model_name_from_attribute(
|
|
612
|
+
imd_attr_or_param, index
|
|
613
|
+
),
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
@staticmethod
|
|
617
|
+
def get_model_name_from_type(type_definition: TypeType, index: Index):
|
|
618
|
+
if type_definition.element_in_package:
|
|
619
|
+
package = index.index[mandatory(type_definition.element_in_package.ref)]
|
|
620
|
+
if isinstance(package, SubModel):
|
|
621
|
+
package = index.index[mandatory_ref(package.element_in_package)]
|
|
622
|
+
return package.name
|
|
623
|
+
else:
|
|
624
|
+
# a type outside of a package is a local type of an attribute
|
|
625
|
+
attribute = index.index[mandatory_ref(type_definition.ltparent)]
|
|
626
|
+
return Attribute.get_model_name_from_attribute(attribute, index)
|
|
627
|
+
|
|
628
|
+
@staticmethod
|
|
629
|
+
def get_model_name_from_attribute(attribute: AttrOrParam, index: Index) -> str:
|
|
630
|
+
parent = Attribute.get_referenced_class(attribute, index)
|
|
631
|
+
package = index.index[mandatory_ref(parent.element_in_package)]
|
|
632
|
+
if isinstance(package, SubModel):
|
|
633
|
+
package = index.index[mandatory_ref(package.element_in_package)]
|
|
634
|
+
return package.name
|
|
635
|
+
|
|
636
|
+
@staticmethod
|
|
637
|
+
def get_last_super_model_name_from_attribute(attribute: AttrOrParam, index: Index) -> str:
|
|
638
|
+
"""
|
|
639
|
+
This method derives the package which the attribute is from. It uses the maybe existing
|
|
640
|
+
super definition to adjust the package to the highest super class. This is because a
|
|
641
|
+
inherited/extended attribute has its origin back from the package/model where it first
|
|
642
|
+
was defined.
|
|
643
|
+
See: https://interlis.discourse.group/t/multilingual-elemente-aus-localisationch-v2-localisation-v2-in-interlis-2-4/423
|
|
644
|
+
|
|
645
|
+
Args:
|
|
646
|
+
attribute:
|
|
647
|
+
index:
|
|
648
|
+
|
|
649
|
+
Returns:
|
|
650
|
+
|
|
651
|
+
"""
|
|
652
|
+
if attribute.tid in index.type_super_classes:
|
|
653
|
+
# here we reset the attribute variable to the highest (last) available element from
|
|
654
|
+
# the inheritance chain!
|
|
655
|
+
attribute = index.index[index.type_super_classes[attribute.tid][-1]]
|
|
656
|
+
return Attribute.get_model_name_from_attribute(attribute, index)
|
|
657
|
+
|
|
658
|
+
@staticmethod
|
|
659
|
+
def decide_type_references(
|
|
660
|
+
source_class: ImdClass, target_type_oids: list[str], index: Index
|
|
661
|
+
):
|
|
662
|
+
types = []
|
|
663
|
+
imports = []
|
|
664
|
+
for super_reference in target_type_oids:
|
|
665
|
+
super_type_name, type_reference_import = Attribute.decide_type_reference(
|
|
666
|
+
source_class, super_reference, index
|
|
667
|
+
)
|
|
668
|
+
if super_type_name not in types:
|
|
669
|
+
types.append(super_type_name)
|
|
670
|
+
if type_reference_import and type_reference_import not in imports:
|
|
671
|
+
imports.append(type_reference_import)
|
|
672
|
+
return types, imports
|
|
673
|
+
|
|
674
|
+
@staticmethod
|
|
675
|
+
def decide_type_reference(source_class: ImdClass, target_type_oid: str, index: Index):
|
|
676
|
+
target_type = index.index[target_type_oid]
|
|
677
|
+
local_type = False
|
|
678
|
+
if target_type.element_in_package:
|
|
679
|
+
# this is a type which is defined as a own class
|
|
680
|
+
target_referenced_class = target_type
|
|
681
|
+
else:
|
|
682
|
+
# this is a type which is defined inline directly with the corresponding attribute
|
|
683
|
+
target_attr_or_param = index.index[target_type.ltparent.ref]
|
|
684
|
+
target_referenced_class = Attribute.get_referenced_class(
|
|
685
|
+
target_attr_or_param, index
|
|
686
|
+
)
|
|
687
|
+
local_type = True
|
|
688
|
+
target_model, target_sub_model = Attribute.get_class_location(
|
|
689
|
+
target_referenced_class, index
|
|
690
|
+
)
|
|
691
|
+
if (
|
|
692
|
+
mandatory_ref(source_class.element_in_package)
|
|
693
|
+
== target_referenced_class.element_in_package.ref
|
|
694
|
+
):
|
|
695
|
+
# source and target in the same package
|
|
696
|
+
if local_type:
|
|
697
|
+
if target_referenced_class.tid != source_class.tid:
|
|
698
|
+
return f"{target_referenced_class.name}.{target_attr_or_param.name}", None
|
|
699
|
+
else:
|
|
700
|
+
return None, None
|
|
701
|
+
else:
|
|
702
|
+
return f"{target_referenced_class.name}", None
|
|
703
|
+
else:
|
|
704
|
+
if target_sub_model:
|
|
705
|
+
package_import_part = f"{target_model.name}.{target_sub_model.name}"
|
|
706
|
+
else:
|
|
707
|
+
package_import_part = f"{target_model.name}"
|
|
708
|
+
if local_type:
|
|
709
|
+
# its a type directly from an attribute of a class, we link to that attribute
|
|
710
|
+
reference_name = Attribute.pythonize_oid_global(target_referenced_class.tid)
|
|
711
|
+
return f"{reference_name}.{target_attr_or_param.name}", (
|
|
712
|
+
package_import_part,
|
|
713
|
+
target_referenced_class.name,
|
|
714
|
+
reference_name,
|
|
715
|
+
)
|
|
716
|
+
else:
|
|
717
|
+
# its a dedicated type class, we link to that class
|
|
718
|
+
reference_name = Attribute.pythonize_oid_global(target_type.tid)
|
|
719
|
+
return f"{reference_name}", (
|
|
720
|
+
package_import_part,
|
|
721
|
+
target_type.name,
|
|
722
|
+
reference_name,
|
|
723
|
+
)
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
@dataclass
|
|
727
|
+
class Class(Base):
|
|
728
|
+
"""Represents imd Class"""
|
|
729
|
+
|
|
730
|
+
oid: Attribute | None = field(default=None)
|
|
731
|
+
super_class: str | None = field(default=None)
|
|
732
|
+
attributes: list[Attribute] = field(default_factory=list)
|
|
733
|
+
abstract: bool = field(default=False)
|
|
734
|
+
related_class_imports: list[RelatedImport] = field(default_factory=list)
|
|
735
|
+
enumerations: list["Enumeration"] = field(default_factory=list)
|
|
736
|
+
kind: str | None = field(default=None)
|
|
737
|
+
existence_constraints: list[dict] = field(default_factory=list)
|
|
738
|
+
set_constraints: list[dict] = field(default_factory=list)
|
|
739
|
+
simple_constraints: list[dict] = field(default_factory=list)
|
|
740
|
+
unique_constraints: list[dict] = field(default_factory=list)
|
|
741
|
+
geom_point_like_attributes: list[Attribute] = field(default_factory=list)
|
|
742
|
+
geom_line_like_attributes: list[Attribute] = field(default_factory=list)
|
|
743
|
+
geom_polygon_like_attributes: list[Attribute] = field(default_factory=list)
|
|
744
|
+
|
|
745
|
+
@property
|
|
746
|
+
def geom_attributes(self):
|
|
747
|
+
return (
|
|
748
|
+
self.geom_polygon_like_attributes
|
|
749
|
+
+ self.geom_line_like_attributes
|
|
750
|
+
+ self.geom_point_like_attributes
|
|
751
|
+
)
|
|
752
|
+
|
|
753
|
+
@classmethod
|
|
754
|
+
def from_imd(cls, imd_class: ImdClass, imd_model_data: ModelData, index: Index):
|
|
755
|
+
tid = mandatory(imd_class.tid)
|
|
756
|
+
package_ref = mandatory_ref(imd_class.element_in_package)
|
|
757
|
+
attributes = []
|
|
758
|
+
related_class_imports: list[RelatedImport] = []
|
|
759
|
+
oid_attribute = None
|
|
760
|
+
if imd_class.oid:
|
|
761
|
+
oid_type_object = index.index[imd_class.oid.ref]
|
|
762
|
+
if oid_type_object.element_in_package.ref == package_ref:
|
|
763
|
+
oid_type_name = oid_type_object.name
|
|
764
|
+
else:
|
|
765
|
+
oid_type_object_package = index.index[oid_type_object.element_in_package.ref]
|
|
766
|
+
if isinstance(oid_type_object_package, SubModel):
|
|
767
|
+
oid_type_object_model = index.index[
|
|
768
|
+
mandatory_ref(oid_type_object_package.element_in_package)
|
|
769
|
+
]
|
|
770
|
+
oid_type_name = (
|
|
771
|
+
f"{oid_type_object_model.name}_{oid_type_object_package.name}_"
|
|
772
|
+
f"{oid_type_object.name}"
|
|
773
|
+
)
|
|
774
|
+
related_class_imports.append(
|
|
775
|
+
(
|
|
776
|
+
f"{oid_type_object_model.name}.{oid_type_object_package.name}",
|
|
777
|
+
oid_type_object.name,
|
|
778
|
+
oid_type_name,
|
|
779
|
+
)
|
|
780
|
+
)
|
|
781
|
+
else:
|
|
782
|
+
oid_type_name = f"{oid_type_object_package.name}_{oid_type_object.name}"
|
|
783
|
+
related_class_imports.append(
|
|
784
|
+
(
|
|
785
|
+
f"{oid_type_object_package.name}",
|
|
786
|
+
oid_type_object.name,
|
|
787
|
+
oid_type_name,
|
|
788
|
+
)
|
|
789
|
+
)
|
|
790
|
+
oid_attribute = Attribute(
|
|
791
|
+
"tid",
|
|
792
|
+
identifier=f"ili2py.{tid}.tid",
|
|
793
|
+
doc=[
|
|
794
|
+
"This attribute is generated by ili2py based on the OID definition in "
|
|
795
|
+
"the underlying model."
|
|
796
|
+
],
|
|
797
|
+
meta_attributes=[],
|
|
798
|
+
types=[oid_type_name],
|
|
799
|
+
type_restrictions=Attribute.construct_type_restrictions(oid_type_object),
|
|
800
|
+
enumeration=None,
|
|
801
|
+
line_type=None,
|
|
802
|
+
type_related_type_class=None,
|
|
803
|
+
)
|
|
804
|
+
point_like_attributes = []
|
|
805
|
+
line_like_attributes = []
|
|
806
|
+
polygon_like_attributes = []
|
|
807
|
+
if index.class_class_attribute.get(tid):
|
|
808
|
+
for imd_attr_or_param_oid in index.class_class_attribute[tid]:
|
|
809
|
+
attribute = Attribute.from_imd(
|
|
810
|
+
index.index[imd_attr_or_param_oid], imd_model_data, index
|
|
811
|
+
)
|
|
812
|
+
attributes.append(attribute)
|
|
813
|
+
if attribute.geometric_is_point_like:
|
|
814
|
+
point_like_attributes.append(attribute)
|
|
815
|
+
if attribute.geometric_is_line_like:
|
|
816
|
+
line_like_attributes.append(attribute)
|
|
817
|
+
if attribute.geometric_is_polygon_like:
|
|
818
|
+
polygon_like_attributes.append(attribute)
|
|
819
|
+
related_class_imports += attribute.type_related_imports
|
|
820
|
+
if tid in index.association_to_class_ref_attributes:
|
|
821
|
+
for role_tid, related_class_tid in index.association_to_class_ref_attributes[tid]:
|
|
822
|
+
role: ImdRole = index.index[role_tid]
|
|
823
|
+
related_class: ImdClass = index.index[related_class_tid]
|
|
824
|
+
type_reference, type_reference_imports = cls.decide_type_reference(
|
|
825
|
+
mandatory(related_class.tid), tid, index
|
|
826
|
+
)
|
|
827
|
+
if type_reference_imports:
|
|
828
|
+
related_class_imports.append(type_reference_imports)
|
|
829
|
+
meta_attributes = cls.assemble_meta_attributes(index, role_tid)
|
|
830
|
+
type_restrictions = Attribute.construct_type_restrictions(role)
|
|
831
|
+
package_name = Attribute.get_model_name_from_type(imd_class, index)
|
|
832
|
+
attributes.append(
|
|
833
|
+
Attribute(
|
|
834
|
+
name=mandatory(role.name),
|
|
835
|
+
identifier=role_tid,
|
|
836
|
+
doc=cls.doc_string(role.documentation),
|
|
837
|
+
types=["Ref"],
|
|
838
|
+
meta_attributes=meta_attributes,
|
|
839
|
+
type_restrictions=type_restrictions,
|
|
840
|
+
reference_targets=[related_class_tid],
|
|
841
|
+
namespace_package=package_name,
|
|
842
|
+
)
|
|
843
|
+
)
|
|
844
|
+
meta_attributes = cls.assemble_meta_attributes(index, tid)
|
|
845
|
+
super_class_reference = None
|
|
846
|
+
if imd_class.super:
|
|
847
|
+
super_class_reference, super_class_reference_imports = cls.decide_type_reference(
|
|
848
|
+
mandatory(imd_class.super.ref), tid, index
|
|
849
|
+
)
|
|
850
|
+
if super_class_reference_imports:
|
|
851
|
+
if (
|
|
852
|
+
len(super_class_reference_imports[0].split(".")) > 1
|
|
853
|
+
and super_class_reference_imports[1] is None
|
|
854
|
+
and super_class_reference_imports[2] is None
|
|
855
|
+
):
|
|
856
|
+
logging.debug(
|
|
857
|
+
"Import was skipped, since it has too many dots: "
|
|
858
|
+
f"{super_class_reference_imports[0]}"
|
|
859
|
+
)
|
|
860
|
+
else:
|
|
861
|
+
related_class_imports.append(super_class_reference_imports)
|
|
862
|
+
return cls(
|
|
863
|
+
identifier=tid,
|
|
864
|
+
name=Class.class_name(imd_class),
|
|
865
|
+
super_class=super_class_reference,
|
|
866
|
+
doc=cls.doc_string(imd_class.documentation),
|
|
867
|
+
attributes=attributes,
|
|
868
|
+
abstract=mandatory(imd_class.abstract),
|
|
869
|
+
related_class_imports=related_class_imports,
|
|
870
|
+
meta_attributes=meta_attributes,
|
|
871
|
+
kind=imd_class.kind,
|
|
872
|
+
oid=oid_attribute,
|
|
873
|
+
existence_constraints=Class.translate_existence_constraint(
|
|
874
|
+
index.class_with_existence_constraints.get(tid, []), index
|
|
875
|
+
),
|
|
876
|
+
set_constraints=Class.translate_set_constraint(
|
|
877
|
+
index.class_with_set_constraints.get(tid, []), index
|
|
878
|
+
),
|
|
879
|
+
simple_constraints=Class.translate_simple_constraint(
|
|
880
|
+
index.class_with_simple_constraints.get(tid, []), index
|
|
881
|
+
),
|
|
882
|
+
unique_constraints=Class.translate_unique_constraint(
|
|
883
|
+
index.class_with_unique_constraints.get(tid, []), index
|
|
884
|
+
),
|
|
885
|
+
geom_point_like_attributes=point_like_attributes,
|
|
886
|
+
geom_line_like_attributes=line_like_attributes,
|
|
887
|
+
geom_polygon_like_attributes=polygon_like_attributes,
|
|
888
|
+
)
|
|
889
|
+
|
|
890
|
+
@staticmethod
|
|
891
|
+
def class_name(imd_class: ImdClass) -> str:
|
|
892
|
+
return mandatory(imd_class.name)
|
|
893
|
+
|
|
894
|
+
@staticmethod
|
|
895
|
+
def translate_path_els(path_els_imd: list[PathOrInspFactorTypePathEls]) -> list[PathEl]:
|
|
896
|
+
translated_path_els = []
|
|
897
|
+
for path_el_imd in path_els_imd:
|
|
898
|
+
path_el = mandatory(path_el_imd.path_el)
|
|
899
|
+
translated_path_els.append(
|
|
900
|
+
PathEl(
|
|
901
|
+
kind=path_el.kind,
|
|
902
|
+
ref=path_el.ref.ref if path_el.ref else None,
|
|
903
|
+
num_index=path_el.num_index,
|
|
904
|
+
spec_index=path_el.spec_index,
|
|
905
|
+
)
|
|
906
|
+
)
|
|
907
|
+
return translated_path_els
|
|
908
|
+
|
|
909
|
+
@staticmethod
|
|
910
|
+
def translate_actual_argument(imd_element: ActualArgumentType) -> ActualArgument:
|
|
911
|
+
object_classes = []
|
|
912
|
+
for object_class in imd_element.object_classes:
|
|
913
|
+
if object_class.class_ref:
|
|
914
|
+
object_classes.append(mandatory_ref(object_class.class_ref.ref))
|
|
915
|
+
return ActualArgument(
|
|
916
|
+
formal_argument=(
|
|
917
|
+
imd_element.formal_argument.ref if imd_element.formal_argument else None
|
|
918
|
+
),
|
|
919
|
+
kind=mandatory(imd_element.kind),
|
|
920
|
+
object_classes=object_classes,
|
|
921
|
+
expression=(
|
|
922
|
+
Class.translate_expression(imd_element.expression.choice)
|
|
923
|
+
if imd_element.expression
|
|
924
|
+
else None
|
|
925
|
+
),
|
|
926
|
+
)
|
|
927
|
+
|
|
928
|
+
@staticmethod
|
|
929
|
+
def translate_path_or_insp_factor(imd_element: PathOrInspFactorType) -> PathOrInspFactor:
|
|
930
|
+
translated_element = PathOrInspFactor(
|
|
931
|
+
path_els=Class.translate_path_els(imd_element.path_els),
|
|
932
|
+
inspection=imd_element.inspection.ref if imd_element.inspection else None,
|
|
933
|
+
)
|
|
934
|
+
return translated_element
|
|
935
|
+
|
|
936
|
+
@staticmethod
|
|
937
|
+
def translate_unit_function(imd_element: UnitFunctionType) -> UnitFunction:
|
|
938
|
+
return UnitFunction(explanation=mandatory(imd_element.explanation))
|
|
939
|
+
|
|
940
|
+
@staticmethod
|
|
941
|
+
def translate_unit_ref(imd_element: UnitRefType) -> UnitRef:
|
|
942
|
+
return UnitRef(unit=imd_element.unit.ref if imd_element.unit else None)
|
|
943
|
+
|
|
944
|
+
@staticmethod
|
|
945
|
+
def translate_attribute_const(imd_element: AttributeConstType) -> AttributeConst:
|
|
946
|
+
return AttributeConst(
|
|
947
|
+
attribute=imd_element.attribute.ref if imd_element.attribute else None
|
|
948
|
+
)
|
|
949
|
+
|
|
950
|
+
@staticmethod
|
|
951
|
+
def translate_class_const(imd_element: ClassConstType) -> ClassConst:
|
|
952
|
+
return ClassConst(
|
|
953
|
+
class_value=imd_element.class_value.ref if imd_element.class_value else None
|
|
954
|
+
)
|
|
955
|
+
|
|
956
|
+
@staticmethod
|
|
957
|
+
def translate_constant(imd_element: ConstantType):
|
|
958
|
+
return Constant(
|
|
959
|
+
value=mandatory(imd_element.value), type=mandatory(imd_element.type_value)
|
|
960
|
+
)
|
|
961
|
+
|
|
962
|
+
@staticmethod
|
|
963
|
+
def translate_runtime_param(imd_element: RuntimeParamRefType) -> RuntimeParamRef:
|
|
964
|
+
return RuntimeParamRef(runtime_param=mandatory_ref(imd_element.runtime_param))
|
|
965
|
+
|
|
966
|
+
@staticmethod
|
|
967
|
+
def translate_function_call(imd_element: FunctionCallType) -> FunctionCall:
|
|
968
|
+
return FunctionCall(
|
|
969
|
+
function=imd_element.function.ref if imd_element.function else None,
|
|
970
|
+
arguments=[
|
|
971
|
+
Class.translate_actual_argument(
|
|
972
|
+
mandatory(function_call_argument.actual_argument)
|
|
973
|
+
)
|
|
974
|
+
for function_call_argument in imd_element.arguments
|
|
975
|
+
],
|
|
976
|
+
)
|
|
977
|
+
|
|
978
|
+
@staticmethod
|
|
979
|
+
def translate_enum_assignment(imd_element: EnumAssignmentType) -> EnumAssignment:
|
|
980
|
+
return EnumAssignment(
|
|
981
|
+
min_enum_value=mandatory_ref(imd_element.min_enum_value),
|
|
982
|
+
max_enum_value=imd_element.max_enum_value.ref
|
|
983
|
+
if imd_element.max_enum_value
|
|
984
|
+
else None,
|
|
985
|
+
value_to_assign=Class.translate_expression(imd_element.value_to_assign.choice)
|
|
986
|
+
if imd_element.value_to_assign
|
|
987
|
+
else None,
|
|
988
|
+
)
|
|
989
|
+
|
|
990
|
+
@staticmethod
|
|
991
|
+
def translate_enum_mapping(imd_element: EnumMappingType) -> EnumMapping:
|
|
992
|
+
translated_element = EnumMapping(
|
|
993
|
+
enum_value=Class.translate_path_or_insp_factor(
|
|
994
|
+
mandatory(imd_element.enum_value.path_or_insp_factor)
|
|
995
|
+
)
|
|
996
|
+
if imd_element.enum_value
|
|
997
|
+
else None,
|
|
998
|
+
cases=[
|
|
999
|
+
Class.translate_enum_assignment(mandatory(case.enum_assignment))
|
|
1000
|
+
for case in imd_element.cases
|
|
1001
|
+
],
|
|
1002
|
+
)
|
|
1003
|
+
return translated_element
|
|
1004
|
+
|
|
1005
|
+
@staticmethod
|
|
1006
|
+
def translate_compound_expression(imd_element: CompoundExprType) -> CompoundExpr:
|
|
1007
|
+
translated_sub_expressions = []
|
|
1008
|
+
for sub_expressions in imd_element.sub_expressions:
|
|
1009
|
+
for expression in sub_expressions.choice or []:
|
|
1010
|
+
translated_expression = Class.translate_expression(expression)
|
|
1011
|
+
if translated_expression is not None:
|
|
1012
|
+
translated_sub_expressions.append(translated_expression)
|
|
1013
|
+
return CompoundExpr(
|
|
1014
|
+
operation=imd_element.operation, sub_expressions=translated_sub_expressions
|
|
1015
|
+
)
|
|
1016
|
+
|
|
1017
|
+
@staticmethod
|
|
1018
|
+
def translate_unary_expression(imd_element: UnaryExprType) -> UnaryExpr:
|
|
1019
|
+
return UnaryExpr(
|
|
1020
|
+
operation=imd_element.operation,
|
|
1021
|
+
sub_expression=Class.translate_expression(imd_element.sub_expression.choice)
|
|
1022
|
+
if imd_element.sub_expression
|
|
1023
|
+
else None,
|
|
1024
|
+
)
|
|
1025
|
+
|
|
1026
|
+
@staticmethod
|
|
1027
|
+
def translate_expression(
|
|
1028
|
+
expression_imd: ImdExpressionType | None,
|
|
1029
|
+
) -> ExpressionType | None:
|
|
1030
|
+
if isinstance(expression_imd, UnitFunctionType):
|
|
1031
|
+
return ExpressionType(choice=Class.translate_unit_function(expression_imd))
|
|
1032
|
+
elif isinstance(expression_imd, UnitRefType):
|
|
1033
|
+
return ExpressionType(choice=Class.translate_unit_ref(expression_imd))
|
|
1034
|
+
elif isinstance(expression_imd, AttributeConstType):
|
|
1035
|
+
return ExpressionType(choice=Class.translate_attribute_const(expression_imd))
|
|
1036
|
+
elif isinstance(expression_imd, ClassConstType):
|
|
1037
|
+
return ExpressionType(choice=Class.translate_class_const(expression_imd))
|
|
1038
|
+
elif isinstance(expression_imd, ConstantType):
|
|
1039
|
+
return ExpressionType(choice=Class.translate_constant(expression_imd))
|
|
1040
|
+
elif isinstance(expression_imd, RuntimeParamRefType):
|
|
1041
|
+
return ExpressionType(choice=Class.translate_runtime_param(expression_imd))
|
|
1042
|
+
elif isinstance(expression_imd, FunctionCallType):
|
|
1043
|
+
return ExpressionType(choice=Class.translate_function_call(expression_imd))
|
|
1044
|
+
elif isinstance(expression_imd, EnumMappingType):
|
|
1045
|
+
return ExpressionType(choice=Class.translate_enum_mapping(expression_imd))
|
|
1046
|
+
elif isinstance(expression_imd, PathOrInspFactorType):
|
|
1047
|
+
return ExpressionType(choice=Class.translate_path_or_insp_factor(expression_imd))
|
|
1048
|
+
elif isinstance(expression_imd, CompoundExprType):
|
|
1049
|
+
return ExpressionType(choice=Class.translate_compound_expression(expression_imd))
|
|
1050
|
+
elif isinstance(expression_imd, UnaryExprType):
|
|
1051
|
+
return ExpressionType(choice=Class.translate_unary_expression(expression_imd))
|
|
1052
|
+
else:
|
|
1053
|
+
logging.debug(f"passed type was: {expression_imd}")
|
|
1054
|
+
return None
|
|
1055
|
+
|
|
1056
|
+
@staticmethod
|
|
1057
|
+
def translate_existence_constraint(constraint_oids: list[str], index: Index) -> list[dict]:
|
|
1058
|
+
translated_constraints = []
|
|
1059
|
+
for oid in constraint_oids:
|
|
1060
|
+
constraint: ExistenceConstraintType = index.index[oid]
|
|
1061
|
+
translated_constraints.append(
|
|
1062
|
+
DictEncoder().encode(
|
|
1063
|
+
ExistenceConstraint(
|
|
1064
|
+
id=mandatory(constraint.tid),
|
|
1065
|
+
name=mandatory(constraint.name),
|
|
1066
|
+
documentation=Class.doc_string(constraint.documentation),
|
|
1067
|
+
to_class=constraint.to_class.ref if constraint.to_class else None,
|
|
1068
|
+
to_domain=constraint.to_domain.ref if constraint.to_domain else None,
|
|
1069
|
+
attr=Class.translate_path_or_insp_factor(
|
|
1070
|
+
mandatory(mandatory(constraint.attr).path_or_insp_factor)
|
|
1071
|
+
),
|
|
1072
|
+
)
|
|
1073
|
+
)
|
|
1074
|
+
)
|
|
1075
|
+
return translated_constraints
|
|
1076
|
+
|
|
1077
|
+
@staticmethod
|
|
1078
|
+
def translate_set_constraint(constraint_oids: list[str], index: Index) -> list[dict]:
|
|
1079
|
+
translated_constraints = []
|
|
1080
|
+
for oid in constraint_oids:
|
|
1081
|
+
constraint: SetConstraintType = index.index[oid]
|
|
1082
|
+
translated_constraint = SetConstraint(
|
|
1083
|
+
id=mandatory(constraint.tid),
|
|
1084
|
+
name=mandatory(constraint.name),
|
|
1085
|
+
documentation=Class.doc_string(constraint.documentation),
|
|
1086
|
+
to_class=constraint.to_class.ref if constraint.to_class else None,
|
|
1087
|
+
to_domain=constraint.to_domain.ref if constraint.to_domain else None,
|
|
1088
|
+
where=(
|
|
1089
|
+
Class.translate_expression(constraint.where.choice)
|
|
1090
|
+
if constraint.where
|
|
1091
|
+
else None
|
|
1092
|
+
),
|
|
1093
|
+
constraint=(
|
|
1094
|
+
Class.translate_expression(constraint.constraint.choice)
|
|
1095
|
+
if constraint.constraint
|
|
1096
|
+
else None
|
|
1097
|
+
),
|
|
1098
|
+
)
|
|
1099
|
+
translated_constraints.append(DictEncoder().encode(translated_constraint))
|
|
1100
|
+
return translated_constraints
|
|
1101
|
+
|
|
1102
|
+
@staticmethod
|
|
1103
|
+
def translate_simple_constraint(constraint_oids: list[str], index: Index) -> list[dict]:
|
|
1104
|
+
translated_constraints = []
|
|
1105
|
+
for oid in constraint_oids:
|
|
1106
|
+
constraint: SimpleConstraintType = index.index[oid]
|
|
1107
|
+
translated_constraint = SimpleConstraint(
|
|
1108
|
+
id=mandatory(constraint.tid),
|
|
1109
|
+
name=mandatory(constraint.name),
|
|
1110
|
+
documentation=Class.doc_string(constraint.documentation),
|
|
1111
|
+
to_class=constraint.to_class.ref if constraint.to_class else None,
|
|
1112
|
+
to_domain=constraint.to_domain.ref if constraint.to_domain else None,
|
|
1113
|
+
kind=constraint.kind,
|
|
1114
|
+
percentage=constraint.percentage,
|
|
1115
|
+
logical_expression=(
|
|
1116
|
+
Class.translate_expression(constraint.logical_expression.choice)
|
|
1117
|
+
if constraint.logical_expression
|
|
1118
|
+
else None
|
|
1119
|
+
),
|
|
1120
|
+
)
|
|
1121
|
+
translated_constraints.append(DictEncoder().encode(translated_constraint))
|
|
1122
|
+
return translated_constraints
|
|
1123
|
+
|
|
1124
|
+
@staticmethod
|
|
1125
|
+
def translate_unique_constraint(constraint_oids: list[str], index: Index) -> list[dict]:
|
|
1126
|
+
translated_constraints = []
|
|
1127
|
+
for oid in constraint_oids:
|
|
1128
|
+
constraint: UniqueConstraintType = index.index[oid]
|
|
1129
|
+
unique_def = []
|
|
1130
|
+
for unique_def_imd in constraint.unique_def:
|
|
1131
|
+
unique_def.append(
|
|
1132
|
+
Class.translate_path_or_insp_factor(
|
|
1133
|
+
mandatory(unique_def_imd.path_or_insp_factor)
|
|
1134
|
+
)
|
|
1135
|
+
)
|
|
1136
|
+
translated_constraints.append(
|
|
1137
|
+
DictEncoder().encode(
|
|
1138
|
+
UniqueConstraint(
|
|
1139
|
+
id=mandatory(constraint.tid),
|
|
1140
|
+
name=mandatory(constraint.name),
|
|
1141
|
+
documentation=Class.doc_string(constraint.documentation),
|
|
1142
|
+
to_class=constraint.to_class.ref if constraint.to_class else None,
|
|
1143
|
+
to_domain=constraint.to_domain.ref if constraint.to_domain else None,
|
|
1144
|
+
kind=mandatory(constraint.kind),
|
|
1145
|
+
unique_def=unique_def,
|
|
1146
|
+
where=(
|
|
1147
|
+
Class.translate_expression(constraint.where.choice)
|
|
1148
|
+
if constraint.where
|
|
1149
|
+
else None
|
|
1150
|
+
),
|
|
1151
|
+
)
|
|
1152
|
+
)
|
|
1153
|
+
)
|
|
1154
|
+
return translated_constraints
|
|
1155
|
+
|
|
1156
|
+
@staticmethod
|
|
1157
|
+
def decide_type_reference(
|
|
1158
|
+
reference: str, class_tid: str, index: Index
|
|
1159
|
+
) -> tuple[str, RelatedImport | None]:
|
|
1160
|
+
super_class = index.index[reference]
|
|
1161
|
+
child_class = index.index[class_tid]
|
|
1162
|
+
# both are classes, they are always defined in a model or topic
|
|
1163
|
+
super_class_package = index.index[mandatory_ref(super_class.element_in_package)]
|
|
1164
|
+
child_class_package = index.index[mandatory_ref(child_class.element_in_package)]
|
|
1165
|
+
if isinstance(super_class_package, Model):
|
|
1166
|
+
if isinstance(child_class_package, Model):
|
|
1167
|
+
if super_class_package.name == child_class_package.name:
|
|
1168
|
+
# both are from same model, so we can simply use the class name as
|
|
1169
|
+
# super reference and dont need any additional imports
|
|
1170
|
+
return super_class.name, None
|
|
1171
|
+
else:
|
|
1172
|
+
# The reference is ok, it can be imported and used directly
|
|
1173
|
+
return reference, (reference, None, None)
|
|
1174
|
+
elif isinstance(child_class_package, SubModel):
|
|
1175
|
+
return reference, (reference, None, None)
|
|
1176
|
+
elif isinstance(super_class_package, SubModel):
|
|
1177
|
+
super_class_model_package = index.index[
|
|
1178
|
+
mandatory_ref(super_class_package.element_in_package)
|
|
1179
|
+
]
|
|
1180
|
+
if isinstance(child_class_package, SubModel):
|
|
1181
|
+
child_class_model_package = index.index[
|
|
1182
|
+
mandatory_ref(child_class_package.element_in_package)
|
|
1183
|
+
]
|
|
1184
|
+
if (
|
|
1185
|
+
child_class_package.name == super_class_package.name
|
|
1186
|
+
and child_class_model_package.name == super_class_model_package.name
|
|
1187
|
+
):
|
|
1188
|
+
# Super class is from the same package
|
|
1189
|
+
return super_class.name, None
|
|
1190
|
+
super_class_reference = (
|
|
1191
|
+
f"{super_class_model_package.name}_{super_class_package.name}_"
|
|
1192
|
+
f"{super_class.name}"
|
|
1193
|
+
)
|
|
1194
|
+
return super_class_reference, (
|
|
1195
|
+
f"{super_class_model_package.name}.{super_class_package.name}",
|
|
1196
|
+
super_class.name,
|
|
1197
|
+
super_class_reference,
|
|
1198
|
+
)
|
|
1199
|
+
raise TypeError(
|
|
1200
|
+
f"Unexpected type while handling super class constructs of class {child_class}"
|
|
1201
|
+
)
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
@dataclass
|
|
1205
|
+
class Choice:
|
|
1206
|
+
type_reference: str = field()
|
|
1207
|
+
name: str = field()
|
|
1208
|
+
identifier: str = field()
|
|
1209
|
+
model_name: str = field()
|
|
1210
|
+
|
|
1211
|
+
|
|
1212
|
+
@dataclass
|
|
1213
|
+
class Basket:
|
|
1214
|
+
choices: list[Choice] = field(default_factory=list)
|
|
1215
|
+
related_class_imports: list[RelatedImport] = field(default_factory=list)
|
|
1216
|
+
|
|
1217
|
+
@classmethod
|
|
1218
|
+
def from_imd(cls, imd_class: DataUnit, index: Index):
|
|
1219
|
+
tid = mandatory(imd_class.tid)
|
|
1220
|
+
choices = []
|
|
1221
|
+
related_class_imports = []
|
|
1222
|
+
for type_oid in index.allowed_in_basket_of_data_unit[tid]:
|
|
1223
|
+
type_object = index.index[type_oid]
|
|
1224
|
+
# a DataUnit is always defined in a topic
|
|
1225
|
+
if type_object.element_in_package.ref == mandatory_ref(
|
|
1226
|
+
imd_class.element_in_package
|
|
1227
|
+
):
|
|
1228
|
+
type_reference = type_object.name
|
|
1229
|
+
else:
|
|
1230
|
+
type_reference, type_reference_imports = Class.decide_type_reference(
|
|
1231
|
+
type_object.tid, tid, index
|
|
1232
|
+
)
|
|
1233
|
+
if type_reference_imports:
|
|
1234
|
+
related_class_imports.append(type_reference_imports)
|
|
1235
|
+
type_model_object = index.index[type_object.element_in_package.ref]
|
|
1236
|
+
if isinstance(type_model_object, SubModel):
|
|
1237
|
+
type_model_object = index.index[
|
|
1238
|
+
mandatory_ref(type_model_object.element_in_package)
|
|
1239
|
+
]
|
|
1240
|
+
choices.append(
|
|
1241
|
+
Choice(
|
|
1242
|
+
type_reference=type_reference,
|
|
1243
|
+
name=type_object.name,
|
|
1244
|
+
identifier=type_object.tid,
|
|
1245
|
+
model_name=type_model_object.name,
|
|
1246
|
+
)
|
|
1247
|
+
)
|
|
1248
|
+
return cls(choices=choices, related_class_imports=related_class_imports)
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
@dataclass
|
|
1252
|
+
class CoordAttribute(Attribute):
|
|
1253
|
+
reference_system: str | None = field(default=None)
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
@dataclass
|
|
1257
|
+
class CoordType(Base):
|
|
1258
|
+
attributes: list[Attribute] = field(default_factory=list)
|
|
1259
|
+
multi: bool = field(default=False)
|
|
1260
|
+
|
|
1261
|
+
@classmethod
|
|
1262
|
+
def from_imd(cls, imd_coord_type: ImdCoordType, imd_model_data: ModelData, index: Index):
|
|
1263
|
+
tid = mandatory(imd_coord_type.tid)
|
|
1264
|
+
attributes: list[Attribute] = []
|
|
1265
|
+
for imd_axis_spec in cls.get_element_of_type_from_list(
|
|
1266
|
+
AxisSpec, imd_model_data.choice
|
|
1267
|
+
):
|
|
1268
|
+
if imd_axis_spec.coord_type.ref == tid:
|
|
1269
|
+
imd_axis = index.index[imd_axis_spec.axis.ref]
|
|
1270
|
+
reference_system = None
|
|
1271
|
+
if imd_axis.ref_sys:
|
|
1272
|
+
reference_system = index.index[imd_axis.ref_sys.ref].tid
|
|
1273
|
+
meta_attributes = cls.assemble_meta_attributes(index, imd_axis.tid)
|
|
1274
|
+
mapped_type, is_tid = Attribute.handle_type_trail(imd_axis, index)
|
|
1275
|
+
attributes.append(
|
|
1276
|
+
CoordAttribute(
|
|
1277
|
+
identifier=imd_axis.tid,
|
|
1278
|
+
name=imd_axis.name,
|
|
1279
|
+
doc=cls.doc_string(imd_axis.documentation),
|
|
1280
|
+
types=[mapped_type],
|
|
1281
|
+
reference_system=reference_system,
|
|
1282
|
+
type_restrictions=CoordAttribute.construct_type_restrictions(imd_axis),
|
|
1283
|
+
meta_attributes=meta_attributes,
|
|
1284
|
+
)
|
|
1285
|
+
)
|
|
1286
|
+
meta_attributes = cls.assemble_meta_attributes(index, tid)
|
|
1287
|
+
return cls(
|
|
1288
|
+
identifier=tid,
|
|
1289
|
+
name=mandatory(imd_coord_type.name),
|
|
1290
|
+
doc=cls.doc_string(imd_coord_type.documentation),
|
|
1291
|
+
attributes=attributes,
|
|
1292
|
+
meta_attributes=meta_attributes,
|
|
1293
|
+
multi=imd_coord_type.multi if imd_coord_type.multi else False,
|
|
1294
|
+
)
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
@dataclass
|
|
1298
|
+
class LineType(Base):
|
|
1299
|
+
attribute: Attribute | None = field(default=None)
|
|
1300
|
+
max_overlap: float | None = field(default=None)
|
|
1301
|
+
straights: bool = field(default=False)
|
|
1302
|
+
arcs: bool = field(default=False)
|
|
1303
|
+
is_line_like: bool = field(default=False)
|
|
1304
|
+
is_polygon_like: bool = field(default=False)
|
|
1305
|
+
multi: bool = field(default=False)
|
|
1306
|
+
|
|
1307
|
+
@classmethod
|
|
1308
|
+
def from_imd(cls, imd_line_type: ImdLineType, index: Index):
|
|
1309
|
+
tid = mandatory(imd_line_type.tid)
|
|
1310
|
+
kind = mandatory(imd_line_type.kind)
|
|
1311
|
+
attribute_doc = []
|
|
1312
|
+
meta_attributes = []
|
|
1313
|
+
if imd_line_type.coord_type:
|
|
1314
|
+
coord_type = index.index[imd_line_type.coord_type.ref]
|
|
1315
|
+
attribute_doc = cls.doc_string(coord_type.documentation)
|
|
1316
|
+
if imd_line_type.element_in_package:
|
|
1317
|
+
if imd_line_type.element_in_package.ref == coord_type.element_in_package.ref:
|
|
1318
|
+
# line_type and coordtype_reference in the same package
|
|
1319
|
+
type_name = coord_type.name.split(".")[-1]
|
|
1320
|
+
else:
|
|
1321
|
+
# line_type and coordtype_reference NOT in the same package
|
|
1322
|
+
type_name = imd_line_type.coord_type.ref
|
|
1323
|
+
else:
|
|
1324
|
+
# line_type and coordtype_reference NOT in the same package
|
|
1325
|
+
type_name = imd_line_type.coord_type.ref
|
|
1326
|
+
meta_attributes = cls.assemble_meta_attributes(index, coord_type.tid)
|
|
1327
|
+
else:
|
|
1328
|
+
type_name = "Any"
|
|
1329
|
+
attribute = Attribute(
|
|
1330
|
+
identifier=f"{tid}_attribute",
|
|
1331
|
+
name=kind.upper(),
|
|
1332
|
+
doc=attribute_doc,
|
|
1333
|
+
types=[type_name],
|
|
1334
|
+
meta_attributes=meta_attributes,
|
|
1335
|
+
)
|
|
1336
|
+
if kind not in ["Polyline", "DirectedPolyline", "Surface", "Area"]:
|
|
1337
|
+
logging.debug(f"LineType kind not recognized {kind}, {imd_line_type}")
|
|
1338
|
+
meta_attributes = cls.assemble_meta_attributes(index, tid)
|
|
1339
|
+
return cls(
|
|
1340
|
+
identifier=tid,
|
|
1341
|
+
name=mandatory(imd_line_type.name),
|
|
1342
|
+
doc=cls.doc_string(imd_line_type.documentation),
|
|
1343
|
+
attribute=attribute,
|
|
1344
|
+
max_overlap=float(imd_line_type.max_overlap)
|
|
1345
|
+
if imd_line_type.max_overlap
|
|
1346
|
+
else None,
|
|
1347
|
+
straights=tid in index.line_form["INTERLIS.STRAIGHTS"],
|
|
1348
|
+
arcs=tid in index.line_form["INTERLIS.ARCS"],
|
|
1349
|
+
meta_attributes=meta_attributes,
|
|
1350
|
+
is_line_like=kind in ["Polyline", "DirectedPolyline"],
|
|
1351
|
+
is_polygon_like=kind in ["Surface", "Area"],
|
|
1352
|
+
multi=imd_line_type.multi if imd_line_type.multi else False,
|
|
1353
|
+
)
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
@dataclass
|
|
1357
|
+
class Value(Base):
|
|
1358
|
+
value: str
|
|
1359
|
+
children: list["Value"] = field(default_factory=list)
|
|
1360
|
+
|
|
1361
|
+
@classmethod
|
|
1362
|
+
def from_imd(cls, imd_enum_node: EnumNode, index: Index):
|
|
1363
|
+
name = mandatory(imd_enum_node.name)
|
|
1364
|
+
return cls(
|
|
1365
|
+
identifier=mandatory(imd_enum_node.tid),
|
|
1366
|
+
name=name,
|
|
1367
|
+
value=name,
|
|
1368
|
+
doc=cls.doc_string(imd_enum_node.documentation),
|
|
1369
|
+
meta_attributes=[],
|
|
1370
|
+
)
|
|
1371
|
+
|
|
1372
|
+
def get_enum_values(self, values: list, current_path: list, tree: bool = False):
|
|
1373
|
+
if tree or len(self.children) == 0:
|
|
1374
|
+
values.append(".".join(current_path + [self.value]))
|
|
1375
|
+
for child in self.children:
|
|
1376
|
+
child.get_enum_values(values, current_path + [self.value], tree=tree)
|
|
1377
|
+
return values
|
|
1378
|
+
|
|
1379
|
+
|
|
1380
|
+
@dataclass
|
|
1381
|
+
class Enumeration(Base):
|
|
1382
|
+
values: list[str] = field(default_factory=list)
|
|
1383
|
+
super_class: str | None = field(default=None)
|
|
1384
|
+
tree: bool = field(default=False)
|
|
1385
|
+
|
|
1386
|
+
@classmethod
|
|
1387
|
+
def get_related_enum_nodes(cls, imd_enum_node: EnumNode, index: Index):
|
|
1388
|
+
related_enum_nodes = []
|
|
1389
|
+
for found_enum_node in index.types_bucket["EnumNode"]:
|
|
1390
|
+
if (
|
|
1391
|
+
found_enum_node.parent_node is not None
|
|
1392
|
+
and found_enum_node.parent_node.ref == imd_enum_node.tid
|
|
1393
|
+
):
|
|
1394
|
+
child_enum_nodes = cls.get_related_enum_nodes(found_enum_node, index)
|
|
1395
|
+
enum_value = Value.from_imd(found_enum_node, index)
|
|
1396
|
+
enum_value.children = child_enum_nodes
|
|
1397
|
+
related_enum_nodes.append(enum_value)
|
|
1398
|
+
return related_enum_nodes
|
|
1399
|
+
|
|
1400
|
+
@classmethod
|
|
1401
|
+
def from_imd(cls, imd_enum_type: EnumType, index: Index):
|
|
1402
|
+
top_enum_node = index.index[f"{imd_enum_type.tid}.TOP"]
|
|
1403
|
+
enum_hirarchie = cls.get_related_enum_nodes(top_enum_node, index)
|
|
1404
|
+
matched_imd_enum_tree_value_type = None
|
|
1405
|
+
for imd_enum_tree_value_type in index.types_bucket.get("EnumTreeValueType", []):
|
|
1406
|
+
if imd_enum_tree_value_type.et.ref == imd_enum_type.tid:
|
|
1407
|
+
matched_imd_enum_tree_value_type = imd_enum_tree_value_type
|
|
1408
|
+
tree = matched_imd_enum_tree_value_type is not None
|
|
1409
|
+
values: list[str] = []
|
|
1410
|
+
for node in enum_hirarchie:
|
|
1411
|
+
values = values + node.get_enum_values([], [], tree=tree)
|
|
1412
|
+
# Shortening the relation between AttrOrParam.type and EnumTreeValueType.tid to the
|
|
1413
|
+
# actual EnumType.tid because an EnumTreeValueType is a EnumType of all nodes and leafs
|
|
1414
|
+
# in the enum tree, see 2.8.2 Aufzählungen in
|
|
1415
|
+
# https://www.interlis.ch/download/interlis2/ili2-refman_2006-04-13_d.pdf
|
|
1416
|
+
# and this is resolved already Values.get_related_enum_nodes
|
|
1417
|
+
if matched_imd_enum_tree_value_type:
|
|
1418
|
+
tid = matched_imd_enum_tree_value_type.tid
|
|
1419
|
+
name = matched_imd_enum_tree_value_type.name
|
|
1420
|
+
else:
|
|
1421
|
+
tid = cls.prepare_tid(mandatory(imd_enum_type.tid))
|
|
1422
|
+
name = imd_enum_type.name
|
|
1423
|
+
meta_attributes = cls.assemble_meta_attributes(index, mandatory(imd_enum_type.tid))
|
|
1424
|
+
return cls(
|
|
1425
|
+
identifier=tid,
|
|
1426
|
+
name=cls.get_name(name, tid),
|
|
1427
|
+
doc=cls.doc_string(imd_enum_type.documentation),
|
|
1428
|
+
super_class=imd_enum_type.super.ref if imd_enum_type.super else None,
|
|
1429
|
+
values=values,
|
|
1430
|
+
tree=tree,
|
|
1431
|
+
meta_attributes=meta_attributes,
|
|
1432
|
+
)
|
|
1433
|
+
|
|
1434
|
+
@staticmethod
|
|
1435
|
+
def prepare_tid(tid: str) -> str:
|
|
1436
|
+
return tid.replace(".TYPE", "_ENUM")
|
|
1437
|
+
|
|
1438
|
+
@staticmethod
|
|
1439
|
+
def get_name(name, identifier) -> str:
|
|
1440
|
+
if name == "TYPE":
|
|
1441
|
+
return "".join(identifier.split(".")[-2:]).replace("_", "")
|
|
1442
|
+
else:
|
|
1443
|
+
return name
|
|
1444
|
+
|
|
1445
|
+
|
|
1446
|
+
@dataclass
|
|
1447
|
+
class Module(Base):
|
|
1448
|
+
"""Represents imd:SubModel aka ili:Topic"""
|
|
1449
|
+
|
|
1450
|
+
classes: list[Class] = field(default_factory=list)
|
|
1451
|
+
enumerations: list[Enumeration] = field(default_factory=list)
|
|
1452
|
+
coord_types: list[CoordType] = field(default_factory=list)
|
|
1453
|
+
line_types: list[LineType] = field(default_factory=list)
|
|
1454
|
+
imported_packages: list[str] = field(default_factory=list)
|
|
1455
|
+
related_class_imports: list[RelatedImport] = field(default_factory=list)
|
|
1456
|
+
library: str | None = field(default=None)
|
|
1457
|
+
type_definitions: list[dict] = field(default_factory=list)
|
|
1458
|
+
basket: Basket | None = field(default=None)
|
|
1459
|
+
|
|
1460
|
+
@classmethod
|
|
1461
|
+
def from_imd(
|
|
1462
|
+
cls,
|
|
1463
|
+
imd_instance: MetaElementType,
|
|
1464
|
+
imd_model_data: ModelData,
|
|
1465
|
+
index: Index,
|
|
1466
|
+
library: str,
|
|
1467
|
+
):
|
|
1468
|
+
tid = mandatory(imd_instance.tid)
|
|
1469
|
+
classes = []
|
|
1470
|
+
related_class_imports: list[RelatedImport] = []
|
|
1471
|
+
for imd_class in cls.get_element_of_type_from_list(
|
|
1472
|
+
ImdClass, imd_model_data.choice, ["Class", "Structure"]
|
|
1473
|
+
):
|
|
1474
|
+
if imd_class.element_in_package.ref == tid:
|
|
1475
|
+
class_instance = Class.from_imd(imd_class, imd_model_data, index)
|
|
1476
|
+
for attribute in class_instance.attributes:
|
|
1477
|
+
if attribute.type_related_type_class:
|
|
1478
|
+
related_class_imports = (
|
|
1479
|
+
related_class_imports
|
|
1480
|
+
+ attribute.type_related_type_class.related_class_imports
|
|
1481
|
+
)
|
|
1482
|
+
classes.append(class_instance)
|
|
1483
|
+
for module_path, class_name, alias in class_instance.related_class_imports:
|
|
1484
|
+
if (module_path, class_name, alias) not in related_class_imports:
|
|
1485
|
+
related_class_imports.append((module_path, class_name, alias))
|
|
1486
|
+
enumerations = []
|
|
1487
|
+
for imd_enumeration in index.types_bucket["EnumType"]:
|
|
1488
|
+
if (
|
|
1489
|
+
imd_enumeration.element_in_package
|
|
1490
|
+
and imd_enumeration.element_in_package.ref == tid
|
|
1491
|
+
):
|
|
1492
|
+
enumerations.append(Enumeration.from_imd(imd_enumeration, index))
|
|
1493
|
+
coord_types = []
|
|
1494
|
+
for imd_coord_type in cls.get_element_of_type_from_list(
|
|
1495
|
+
ImdCoordType, imd_model_data.choice
|
|
1496
|
+
):
|
|
1497
|
+
if (
|
|
1498
|
+
imd_coord_type.element_in_package
|
|
1499
|
+
and imd_coord_type.element_in_package.ref == tid
|
|
1500
|
+
):
|
|
1501
|
+
coord_types.append(CoordType.from_imd(imd_coord_type, imd_model_data, index))
|
|
1502
|
+
line_types = []
|
|
1503
|
+
for imd_line_type in cls.get_element_of_type_from_list(
|
|
1504
|
+
ImdLineType, imd_model_data.choice
|
|
1505
|
+
):
|
|
1506
|
+
if (
|
|
1507
|
+
imd_line_type.element_in_package
|
|
1508
|
+
and imd_line_type.element_in_package.ref == tid
|
|
1509
|
+
):
|
|
1510
|
+
line_types.append(LineType.from_imd(imd_line_type, index))
|
|
1511
|
+
meta_attributes = cls.assemble_meta_attributes(index, tid)
|
|
1512
|
+
type_definitions = []
|
|
1513
|
+
elements = index.elements_in_package.get(tid, [])
|
|
1514
|
+
if not elements:
|
|
1515
|
+
logging.debug(f"No elements in package {imd_instance}")
|
|
1516
|
+
else:
|
|
1517
|
+
for element in index.types_in_domain.get(tid, []):
|
|
1518
|
+
if isinstance(element, (TextType, NumType, FormattedType)):
|
|
1519
|
+
reference, is_oid = Attribute.handle_type_trail(element, index)
|
|
1520
|
+
if element.tid == reference:
|
|
1521
|
+
reference = mandatory_ref(element.super)
|
|
1522
|
+
if is_oid:
|
|
1523
|
+
referenced_element = index.index[reference]
|
|
1524
|
+
if (
|
|
1525
|
+
referenced_element.element_in_package
|
|
1526
|
+
and referenced_element.element_in_package.ref == tid
|
|
1527
|
+
):
|
|
1528
|
+
reference = referenced_element.name
|
|
1529
|
+
kind = "text"
|
|
1530
|
+
if isinstance(element, NumType):
|
|
1531
|
+
float_kind = Attribute.check_type_float(element)
|
|
1532
|
+
kind = "float" if float_kind else "int"
|
|
1533
|
+
type_definitions.append(
|
|
1534
|
+
{
|
|
1535
|
+
"oid": element.tid,
|
|
1536
|
+
"name": element.name,
|
|
1537
|
+
"restrictions": Attribute.construct_type_restrictions(element),
|
|
1538
|
+
"reference": reference,
|
|
1539
|
+
"kind": kind,
|
|
1540
|
+
"existence_constraints": Class.translate_existence_constraint(
|
|
1541
|
+
index.domain_with_existence_constraints.get(element.tid, []),
|
|
1542
|
+
index,
|
|
1543
|
+
),
|
|
1544
|
+
"set_constraints": Class.translate_set_constraint(
|
|
1545
|
+
index.domain_with_set_constraints.get(element.tid, []), index
|
|
1546
|
+
),
|
|
1547
|
+
"simple_constraints": Class.translate_simple_constraint(
|
|
1548
|
+
index.domain_with_simple_constraints.get(element.tid, []),
|
|
1549
|
+
index,
|
|
1550
|
+
),
|
|
1551
|
+
"unique_constraints": Class.translate_unique_constraint(
|
|
1552
|
+
index.domain_with_unique_constraints.get(element.tid, []),
|
|
1553
|
+
index,
|
|
1554
|
+
),
|
|
1555
|
+
}
|
|
1556
|
+
)
|
|
1557
|
+
basket = None
|
|
1558
|
+
basket_ref = index.topic_basket.get(tid)
|
|
1559
|
+
if basket_ref:
|
|
1560
|
+
basket = Basket.from_imd(index.index[basket_ref], index)
|
|
1561
|
+
related_class_imports = related_class_imports + basket.related_class_imports
|
|
1562
|
+
association_oids = index.elements_in_package_class_association.get(tid)
|
|
1563
|
+
if association_oids:
|
|
1564
|
+
for association_oid in association_oids:
|
|
1565
|
+
association_object = index.index[association_oid]
|
|
1566
|
+
association_construct = index.association_bucket.get(association_oid)
|
|
1567
|
+
own_class = False
|
|
1568
|
+
attributes: list[Attribute] = []
|
|
1569
|
+
# https://github.com/rudert-geoinformatik/ili2py/blob/master/tests/data/ilismeta16/ili2-refman_2006-04-13_d.pdf
|
|
1570
|
+
# chapter 3.3.9 (page 87)
|
|
1571
|
+
if association_construct:
|
|
1572
|
+
logging.debug(
|
|
1573
|
+
"Deciding if association is embedded or own class "
|
|
1574
|
+
f"{association_object}"
|
|
1575
|
+
)
|
|
1576
|
+
if len(association_construct) > 2:
|
|
1577
|
+
logging.debug(" Association has > 2 roles => own class")
|
|
1578
|
+
own_class = True
|
|
1579
|
+
elif all(
|
|
1580
|
+
index.index[role_oid].multiplicity.multiplicity.max is None
|
|
1581
|
+
or index.index[role_oid].multiplicity.multiplicity.max > 1
|
|
1582
|
+
for role_oid, *_ in association_construct
|
|
1583
|
+
):
|
|
1584
|
+
logging.debug(
|
|
1585
|
+
" Association roles multiplicities are > 1 => own class"
|
|
1586
|
+
)
|
|
1587
|
+
own_class = True
|
|
1588
|
+
elif all(
|
|
1589
|
+
hasattr(index.index[role_oid], "oid")
|
|
1590
|
+
and index.index[role_oid].oid is not None
|
|
1591
|
+
for role_oid, *_ in association_construct
|
|
1592
|
+
):
|
|
1593
|
+
logging.debug(" Association has OID => own class")
|
|
1594
|
+
own_class = True
|
|
1595
|
+
# special check for own association class based on external references
|
|
1596
|
+
elif len(association_construct) == 2:
|
|
1597
|
+
logging.debug(
|
|
1598
|
+
" Association has 2 Role definitions, checking how to embedd..."
|
|
1599
|
+
)
|
|
1600
|
+
same_topic2 = (
|
|
1601
|
+
index.index[association_construct[1][1]].element_in_package.ref
|
|
1602
|
+
== tid
|
|
1603
|
+
)
|
|
1604
|
+
same_topic1 = (
|
|
1605
|
+
index.index[association_construct[0][1]].element_in_package.ref
|
|
1606
|
+
== tid
|
|
1607
|
+
)
|
|
1608
|
+
if not same_topic1 and not same_topic2:
|
|
1609
|
+
logging.debug(
|
|
1610
|
+
" Embedding Association: Both referenced classes are "
|
|
1611
|
+
"in a different "
|
|
1612
|
+
"topic, we need a own class for the association "
|
|
1613
|
+
f"{association_object}"
|
|
1614
|
+
)
|
|
1615
|
+
own_class = True
|
|
1616
|
+
else:
|
|
1617
|
+
if same_topic2:
|
|
1618
|
+
logging.debug(
|
|
1619
|
+
" Embedding Association: Referenced Class of "
|
|
1620
|
+
"second role is in same topic, "
|
|
1621
|
+
"assuming the association is embedded there and we dont "
|
|
1622
|
+
"need an own class "
|
|
1623
|
+
f"for {association_object}"
|
|
1624
|
+
)
|
|
1625
|
+
own_class = False
|
|
1626
|
+
elif same_topic1:
|
|
1627
|
+
logging.debug(
|
|
1628
|
+
" Embedding Association: Referenced Class of first "
|
|
1629
|
+
"role is in same topic, "
|
|
1630
|
+
"assuming the association is embedded there and we dont "
|
|
1631
|
+
"need an own class "
|
|
1632
|
+
f"for {association_object}"
|
|
1633
|
+
)
|
|
1634
|
+
own_class = False
|
|
1635
|
+
|
|
1636
|
+
if len(index.class_subclassed_by.get(association_object.tid, [])) > 0:
|
|
1637
|
+
logging.debug(
|
|
1638
|
+
" Associaction has Subclasses, we construct a class for "
|
|
1639
|
+
"validity reason "
|
|
1640
|
+
f"(Dataclasses) {association_object}"
|
|
1641
|
+
)
|
|
1642
|
+
own_class = True
|
|
1643
|
+
|
|
1644
|
+
if own_class:
|
|
1645
|
+
association_attribute_names: list[str] = []
|
|
1646
|
+
for (
|
|
1647
|
+
role_oid,
|
|
1648
|
+
referenced_class_oid,
|
|
1649
|
+
_strongness,
|
|
1650
|
+
_min,
|
|
1651
|
+
_max,
|
|
1652
|
+
) in association_construct:
|
|
1653
|
+
role_object: ImdRole = index.index[role_oid]
|
|
1654
|
+
role_name = mandatory(role_object.name)
|
|
1655
|
+
if role_name in association_attribute_names:
|
|
1656
|
+
logging.debug(
|
|
1657
|
+
"We skip association attribute. Attribute with same name "
|
|
1658
|
+
"was added "
|
|
1659
|
+
"already (this is likely due to an OR role combination "
|
|
1660
|
+
"in "
|
|
1661
|
+
f"{association_object.tid}) => {role_object}"
|
|
1662
|
+
)
|
|
1663
|
+
attributes[
|
|
1664
|
+
association_attribute_names.index(role_name)
|
|
1665
|
+
].reference_targets.append(referenced_class_oid)
|
|
1666
|
+
continue
|
|
1667
|
+
association_attribute_names.append(role_name)
|
|
1668
|
+
package_name = Attribute.get_model_name_from_type(
|
|
1669
|
+
association_object, index
|
|
1670
|
+
)
|
|
1671
|
+
attributes.append(
|
|
1672
|
+
Attribute(
|
|
1673
|
+
name=role_name,
|
|
1674
|
+
identifier=role_oid,
|
|
1675
|
+
doc=cls.doc_string(role_object.documentation),
|
|
1676
|
+
meta_attributes=cls.assemble_meta_attributes(
|
|
1677
|
+
index, role_oid
|
|
1678
|
+
),
|
|
1679
|
+
types=["Ref"],
|
|
1680
|
+
type_restrictions=Attribute.construct_type_restrictions(
|
|
1681
|
+
role_object
|
|
1682
|
+
),
|
|
1683
|
+
enumeration=None,
|
|
1684
|
+
line_type=None,
|
|
1685
|
+
reference_targets=[referenced_class_oid],
|
|
1686
|
+
namespace_package=package_name,
|
|
1687
|
+
)
|
|
1688
|
+
)
|
|
1689
|
+
super_reference = None
|
|
1690
|
+
type_reference_imports: list[RelatedImport] = []
|
|
1691
|
+
if association_object.super:
|
|
1692
|
+
super_reference, type_reference_import = Class.decide_type_reference(
|
|
1693
|
+
association_object.super.ref, association_object.tid, index
|
|
1694
|
+
)
|
|
1695
|
+
if type_reference_import:
|
|
1696
|
+
type_reference_imports = [type_reference_import]
|
|
1697
|
+
related_class_imports.append(type_reference_import)
|
|
1698
|
+
if super_reference or attributes:
|
|
1699
|
+
classes.append(
|
|
1700
|
+
Class(
|
|
1701
|
+
name=association_object.name,
|
|
1702
|
+
identifier=association_object.tid,
|
|
1703
|
+
doc=cls.doc_string(association_object.documentation),
|
|
1704
|
+
meta_attributes=cls.assemble_meta_attributes(
|
|
1705
|
+
index, association_object.tid
|
|
1706
|
+
),
|
|
1707
|
+
super_class=super_reference,
|
|
1708
|
+
attributes=attributes,
|
|
1709
|
+
abstract=association_object.abstract,
|
|
1710
|
+
related_class_imports=type_reference_imports,
|
|
1711
|
+
enumerations=[],
|
|
1712
|
+
kind="Association",
|
|
1713
|
+
)
|
|
1714
|
+
)
|
|
1715
|
+
return cls(
|
|
1716
|
+
identifier=tid,
|
|
1717
|
+
name=mandatory(imd_instance.name),
|
|
1718
|
+
doc=cls.doc_string(imd_instance.documentation),
|
|
1719
|
+
classes=classes,
|
|
1720
|
+
enumerations=enumerations,
|
|
1721
|
+
coord_types=coord_types,
|
|
1722
|
+
line_types=line_types,
|
|
1723
|
+
imported_packages=[],
|
|
1724
|
+
library=library,
|
|
1725
|
+
related_class_imports=related_class_imports,
|
|
1726
|
+
meta_attributes=meta_attributes,
|
|
1727
|
+
type_definitions=type_definitions,
|
|
1728
|
+
basket=basket,
|
|
1729
|
+
)
|
|
1730
|
+
|
|
1731
|
+
|
|
1732
|
+
@dataclass
|
|
1733
|
+
class Package(Module):
|
|
1734
|
+
"""
|
|
1735
|
+
Represents a python package, this is a folder containing an __init__.py file. The folder
|
|
1736
|
+
gets the name of the model, the documentation goes into the __init__.py file.
|
|
1737
|
+
"""
|
|
1738
|
+
|
|
1739
|
+
version: str | None = field(default=None)
|
|
1740
|
+
ili_version: str | None = field(default=None)
|
|
1741
|
+
modules: list[Module] = field(default_factory=list)
|
|
1742
|
+
|
|
1743
|
+
@classmethod
|
|
1744
|
+
def from_imd(
|
|
1745
|
+
cls,
|
|
1746
|
+
imd_instance: MetaElementType,
|
|
1747
|
+
imd_model_data: ModelData,
|
|
1748
|
+
index: Index,
|
|
1749
|
+
library: str,
|
|
1750
|
+
):
|
|
1751
|
+
if not isinstance(imd_instance, Model):
|
|
1752
|
+
raise TypeError(f'imd_instance has to be of type "Model" but was {imd_instance}')
|
|
1753
|
+
# set correct typing
|
|
1754
|
+
imd_model: Model = imd_instance
|
|
1755
|
+
|
|
1756
|
+
# call Module function to initialize
|
|
1757
|
+
partialy_initialized_package = super().from_imd(
|
|
1758
|
+
imd_instance, imd_model_data, index, library
|
|
1759
|
+
)
|
|
1760
|
+
modules = []
|
|
1761
|
+
imported_packages = index.importing_p[imd_instance.tid]
|
|
1762
|
+
for imd_submodel in cls.get_element_of_type_from_list(SubModel, imd_model_data.choice):
|
|
1763
|
+
module = Module.from_imd(imd_submodel, imd_model_data, index, library)
|
|
1764
|
+
# we add imported packages from module level here too, this is necessary since we
|
|
1765
|
+
# split things into nested files (python style)
|
|
1766
|
+
module.imported_packages = imported_packages + [partialy_initialized_package.name]
|
|
1767
|
+
modules.append(module)
|
|
1768
|
+
return cls(
|
|
1769
|
+
identifier=mandatory(imd_model.tid),
|
|
1770
|
+
name=mandatory(imd_model.name),
|
|
1771
|
+
version=imd_model.version,
|
|
1772
|
+
ili_version=mandatory(imd_model.ili_version),
|
|
1773
|
+
doc=cls.doc_string(imd_model.documentation),
|
|
1774
|
+
modules=modules,
|
|
1775
|
+
enumerations=partialy_initialized_package.enumerations,
|
|
1776
|
+
classes=partialy_initialized_package.classes,
|
|
1777
|
+
coord_types=partialy_initialized_package.coord_types,
|
|
1778
|
+
line_types=partialy_initialized_package.line_types,
|
|
1779
|
+
imported_packages=imported_packages,
|
|
1780
|
+
library=library,
|
|
1781
|
+
related_class_imports=partialy_initialized_package.related_class_imports,
|
|
1782
|
+
meta_attributes=partialy_initialized_package.meta_attributes,
|
|
1783
|
+
type_definitions=partialy_initialized_package.type_definitions,
|
|
1784
|
+
)
|
|
1785
|
+
|
|
1786
|
+
|
|
1787
|
+
@dataclass
|
|
1788
|
+
class Library(Base):
|
|
1789
|
+
packages: list[Package] = field(default_factory=list)
|
|
1790
|
+
topic_choices: list[Choice] = field(default_factory=list)
|
|
1791
|
+
related_class_imports: list[tuple[str, str, str]] = field(default_factory=list)
|
|
1792
|
+
|
|
1793
|
+
@classmethod
|
|
1794
|
+
def from_imd(cls, imd_model_data_list: list[ModelData], index: Index, name):
|
|
1795
|
+
packages = []
|
|
1796
|
+
topic_choices = []
|
|
1797
|
+
related_class_imports = []
|
|
1798
|
+
for imd_model_data in imd_model_data_list:
|
|
1799
|
+
for model in cls.get_element_of_type_from_list(Model, imd_model_data.choice):
|
|
1800
|
+
package = Package.from_imd(model, imd_model_data, index, name)
|
|
1801
|
+
packages.append(package)
|
|
1802
|
+
for module in package.modules:
|
|
1803
|
+
if module.basket and module.basket.choices:
|
|
1804
|
+
basket_reference = f"{package.name}_{module.name}_{module.name}TOPIC"
|
|
1805
|
+
related_class_imports.append(
|
|
1806
|
+
(
|
|
1807
|
+
f"{package.name}.{module.name}",
|
|
1808
|
+
f"{module.name}TOPIC",
|
|
1809
|
+
basket_reference,
|
|
1810
|
+
)
|
|
1811
|
+
)
|
|
1812
|
+
topic_choices.append(
|
|
1813
|
+
Choice(
|
|
1814
|
+
type_reference=basket_reference,
|
|
1815
|
+
name=module.name,
|
|
1816
|
+
model_name=package.name,
|
|
1817
|
+
identifier=module.identifier,
|
|
1818
|
+
)
|
|
1819
|
+
)
|
|
1820
|
+
|
|
1821
|
+
return cls(
|
|
1822
|
+
name=name,
|
|
1823
|
+
doc=["This library was created with ili2py"],
|
|
1824
|
+
packages=packages,
|
|
1825
|
+
identifier=name,
|
|
1826
|
+
meta_attributes=[],
|
|
1827
|
+
topic_choices=topic_choices,
|
|
1828
|
+
related_class_imports=related_class_imports,
|
|
1829
|
+
)
|