2121"""Abstraction of the SonarQube Quality Profile concept"""
2222
2323from __future__ import annotations
24- from typing import Optional
24+ from typing import Optional , Any
2525import json
2626from datetime import datetime
2727import concurrent .futures
@@ -754,6 +754,21 @@ def flatten(qp_list: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
754754 return flat_list
755755
756756
757+ def __convert_children_to_list (qp_json : dict [str , Any ]) -> list [dict [str , Any ]]:
758+ """Converts a profile's children profiles to list"""
759+ for v in qp_json .values ():
760+ if "children" in v :
761+ v ["children" ] = __convert_children_to_list (v ["children" ])
762+ return util .dict_to_list (qp_json , "name" )
763+
764+
765+ def __convert_profiles_to_list (qp_json : dict [str , Any ]) -> list [dict [str , Any ]]:
766+ """Converts a language top level list of profiles to list"""
767+ for k , v in qp_json .items ():
768+ qp_json [k ] = __convert_children_to_list (v )
769+ return util .dict_to_list (qp_json , "language" , "profiles" )
770+
771+
757772def export (endpoint : pf .Platform , export_settings : types .ConfigSettings , ** kwargs ) -> types .ObjectJsonRepr :
758773 """Exports all or a list of quality profiles configuration as dict
759774
@@ -772,10 +787,12 @@ def export(endpoint: pf.Platform, export_settings: types.ConfigSettings, **kwarg
772787 qp_list [lang ] = {}
773788 qp_list [lang ][name ] = json_data
774789 qp_list = hierarchize (qp_list , endpoint = endpoint )
790+ qp_list = __convert_profiles_to_list (qp_list )
775791 if write_q := kwargs .get ("write_q" , None ):
776792 write_q .put (qp_list )
777793 write_q .put (util .WRITE_END )
778- return dict (sorted (qp_list .items ()))
794+ # return dict(sorted(qp_list.items()))
795+ return qp_list
779796
780797
781798def get_object (endpoint : pf .Platform , name : str , language : str ) -> Optional [QualityProfile ]:
0 commit comments