Skip to content

Commit

Permalink
Check lang_pack to prevent code from breaking when not moderpython
Browse files Browse the repository at this point in the history
Signed-off-by: HUG0-D <[email protected]>
  • Loading branch information
HUG0-D committed Oct 28, 2024
1 parent 16d5f67 commit 26640c4
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions cimgen/cimgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,28 +510,43 @@ def _write_python_files(elem_dict, lang_pack, output_path, version):

lang_pack.set_float_classes(float_classes)
lang_pack.set_enum_classes(enum_classes)
lang_pack.set_primitive_classes(primitive_classes)
lang_pack.set_cim_data_type_classes(cim_data_type_classes)
if "modernpython" in lang_pack.__name__:
lang_pack.set_primitive_classes(primitive_classes)
lang_pack.set_cim_data_type_classes(cim_data_type_classes)

recommended_class_profiles = _get_recommended_class_profiles(elem_dict)

for class_name in elem_dict.keys():

class_details = {
"attributes": _find_multiple_attributes(elem_dict[class_name].attributes()),
"class_location": lang_pack.get_class_location(class_name, elem_dict, output_path),
"class_name": class_name,
"class_origin": elem_dict[class_name].origins(),
"instances": elem_dict[class_name].instances(),
"has_instances": elem_dict[class_name].has_instances(),
"is_a_float": elem_dict[class_name].is_a_float(),
"is_a_primitive": elem_dict[class_name].is_a_primitive(),
"is_a_cim_data_type": elem_dict[class_name].is_a_cim_datatype(),
"langPack": lang_pack,
"sub_class_of": elem_dict[class_name].superClass(),
"sub_classes": elem_dict[class_name].subClasses(),
"recommended_class_profile": recommended_class_profiles[class_name],
}
if "modernpython" in lang_pack.__name__:
class_details = {
"attributes": _find_multiple_attributes(elem_dict[class_name].attributes()),
"class_location": lang_pack.get_class_location(class_name, elem_dict, output_path),
"class_name": class_name,
"class_origin": elem_dict[class_name].origins(),
"instances": elem_dict[class_name].instances(),
"has_instances": elem_dict[class_name].has_instances(),
"is_a_float": elem_dict[class_name].is_a_float(),
"is_a_primitive": elem_dict[class_name].is_a_primitive(),
"is_a_cim_data_type": elem_dict[class_name].is_a_cim_datatype(),
"langPack": lang_pack,
"sub_class_of": elem_dict[class_name].superClass(),
"sub_classes": elem_dict[class_name].subClasses(),
"recommended_class_profile": recommended_class_profiles[class_name],
}
else:
class_details = {
"attributes": _find_multiple_attributes(elem_dict[class_name].attributes()),
"class_location": lang_pack.get_class_location(class_name, elem_dict, output_path),
"class_name": class_name,
"class_origin": elem_dict[class_name].origins(),
"instances": elem_dict[class_name].instances(),
"has_instances": elem_dict[class_name].has_instances(),
"is_a_float": elem_dict[class_name].is_a_float(),
"langPack": lang_pack,
"sub_class_of": elem_dict[class_name].superClass(),
"sub_classes": elem_dict[class_name].subClasses(),
"recommended_class_profile": recommended_class_profiles[class_name],
}

# extract comments
if elem_dict[class_name].comment:
Expand Down

0 comments on commit 26640c4

Please sign in to comment.