Skip to content

Commit 1620adf

Browse files
committed
Add QP JSON conversion functions
1 parent b5e92c8 commit 1620adf

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

sonar/qualityprofiles.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -789,21 +789,6 @@ def flatten(qp_list: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
789789
return flat_list
790790

791791

792-
def __convert_children_to_list(qp_json: dict[str, Any]) -> list[dict[str, Any]]:
793-
"""Converts a profile's children profiles to list"""
794-
for v in qp_json.values():
795-
if "children" in v:
796-
v["children"] = __convert_children_to_list(v["children"])
797-
return util.dict_to_list(qp_json, "name")
798-
799-
800-
def __convert_profiles_to_list(qp_json: dict[str, Any]) -> list[dict[str, Any]]:
801-
"""Converts a language top level list of profiles to list"""
802-
for k, v in qp_json.items():
803-
qp_json[k] = __convert_children_to_list(v)
804-
return util.dict_to_list(qp_json, "language", "profiles")
805-
806-
807792
def export(endpoint: pf.Platform, export_settings: types.ConfigSettings, **kwargs) -> types.ObjectJsonRepr:
808793
"""Exports all or a list of quality profiles configuration as dict
809794
@@ -917,3 +902,18 @@ def convert_one_qp_yaml(qp: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
917902
qp[_CHILDREN_KEY] = {k: convert_one_qp_yaml(q) for k, q in qp[_CHILDREN_KEY].items()}
918903
qp[_CHILDREN_KEY] = util.dict_to_list(qp[_CHILDREN_KEY], "name")
919904
return qp
905+
906+
907+
def __convert_children_to_list(qp_json: dict[str, Any]) -> list[dict[str, Any]]:
908+
"""Converts a profile's children profiles to list"""
909+
for v in qp_json.values():
910+
if "children" in v:
911+
v["children"] = __convert_children_to_list(v["children"])
912+
return util.dict_to_list(qp_json, "name")
913+
914+
915+
def old_to_new_json(qp_json: dict[str, Any]) -> list[dict[str, Any]]:
916+
"""Converts a language top level list of profiles to list"""
917+
for k, v in qp_json.items():
918+
qp_json[k] = __convert_children_to_list(v)
919+
return util.dict_to_list(qp_json, "language", "profiles")

0 commit comments

Comments
 (0)