Skip to content

Commit 9f21bbb

Browse files
committed
Remove convert_for_yaml()
1 parent 64eddac commit 9f21bbb

File tree

10 files changed

+0
-102
lines changed

10 files changed

+0
-102
lines changed

sonar/applications.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -598,16 +598,3 @@ def search_by_name(endpoint: pf.Platform, name: str) -> dict[str, Application]:
598598
data[app.key] = app
599599
# return {app.key: app for app in Application.CACHE.values() if app.name == name}
600600
return data
601-
602-
603-
def convert_for_yaml(original_json: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
604-
"""Convert the original JSON defined for JSON export into a JSON format more adapted for YAML export"""
605-
new_json = util.dict_to_list(util.remove_nones(original_json), "key")
606-
for app_json in new_json:
607-
app_json["branches"] = util.dict_to_list(app_json["branches"], "name")
608-
for b in app_json["branches"]:
609-
if "projects" in b:
610-
b["projects"] = [{"key": k, "branch": br} for k, br in b["projects"].items()]
611-
if "permissions" in app_json:
612-
app_json["permissions"] = permissions.convert_for_yaml(app_json["permissions"])
613-
return new_json

sonar/groups.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,3 @@ def exists(endpoint: pf.Platform, name: str) -> bool:
432432
:return: whether the group exists
433433
"""
434434
return Group.get_object(endpoint=endpoint, name=name) is not None
435-
436-
437-
def convert_for_yaml(original_json: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
438-
"""Convert the original JSON defined for JSON export into a JSON format more adapted for YAML export"""
439-
return util.dict_to_list(util.remove_nones(original_json), "name", "description")

sonar/permissions/permissions.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,3 @@ def black_list(perms: types.JsonPermissions, disallowed_perms: list[str]) -> typ
430430
for user_or_group, original_perms in sub_perms.items():
431431
resulting_perms[perm_type][user_or_group] = [p for p in original_perms if p not in disallowed_perms]
432432
return resulting_perms
433-
434-
435-
def convert_for_yaml(json_perms: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
436-
"""Converts permissions in a format that is more friendly for YAML"""
437-
converted_perms = []
438-
for ptype in "groups", "users":
439-
if ptype in json_perms:
440-
converted_perms += utilities.dict_to_list(json_perms[ptype], ptype[:-1], "permissions")
441-
return converted_perms

sonar/platform.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -942,28 +942,6 @@ def _check_for_retry(response: requests.models.Response) -> tuple[bool, str]:
942942
return False, None
943943

944944

945-
def convert_for_yaml(original_json: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
946-
"""Convert the original JSON defined for JSON export into a JSON format more adapted for YAML export"""
947-
original_json = util.remove_nones(original_json)
948-
if "plugins" in original_json:
949-
original_json["plugins"] = util.dict_to_list(original_json["plugins"], "key", "version")
950-
if "languages" in original_json:
951-
original_json["languages"] = util.dict_to_list(original_json["languages"], "language")
952-
if "permissions" in original_json:
953-
original_json["permissions"] = permissions.convert_for_yaml(original_json["permissions"])
954-
if "permissionTemplates" in original_json:
955-
for tpl in original_json["permissionTemplates"].values():
956-
if "permissions" in tpl:
957-
tpl["permissions"] = permissions.convert_for_yaml(tpl["permissions"])
958-
original_json["permissionTemplates"] = util.dict_to_list(original_json["permissionTemplates"], "name")
959-
if "devopsIntegration" in original_json:
960-
original_json["devopsIntegration"] = util.dict_to_list(original_json["devopsIntegration"], "name")
961-
for key in ("analysisScope", "authentication", "generalSettings", "linters"):
962-
if key in original_json:
963-
original_json[key] = util.dict_to_list(original_json[key], "key", "value")
964-
return original_json
965-
966-
967945
def export(endpoint: Platform, export_settings: types.ConfigSettings, **kwargs) -> types.ObjectJsonRepr:
968946
"""Exports all or a list of projects configuration as dict
969947

sonar/portfolios.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -847,23 +847,6 @@ def get_api_branch(branch: str) -> str:
847847
return branch if branch != c.DEFAULT_BRANCH else None
848848

849849

850-
def convert_for_yaml(original_json: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
851-
"""Convert the original JSON defined for JSON export into a JSON format more adapted for YAML export"""
852-
new_json = util.dict_to_list(util.remove_nones(original_json), "key")
853-
for p_json in new_json:
854-
try:
855-
p_json["projects"] = [{"key": k, "branch": br} for k, br in p_json["projects"]["manual"].items()]
856-
except KeyError:
857-
pass
858-
if "portfolios" in p_json:
859-
p_json["portfolios"] = convert_for_yaml(p_json["portfolios"])
860-
if "applications" in p_json:
861-
p_json["applications"] = [{"key": k, "branches": br} for k, br in p_json["applications"].items()]
862-
if "permissions" in p_json:
863-
p_json["permissions"] = perms.convert_for_yaml(p_json["permissions"])
864-
return new_json
865-
866-
867850
def clear_cache(endpoint: pf.Platform) -> None:
868851
"""Clears the cache of an endpoint"""
869852
Portfolio.clear_cache(endpoint)

sonar/projects.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,12 +1707,3 @@ def convert_proj_for_yaml(proj_json: types.ObjectJsonRepr) -> types.ObjectJsonRe
17071707
if "permissions" in proj_json:
17081708
proj_json["permissions"] = perms.convert_for_yaml(proj_json["permissions"])
17091709
return proj_json
1710-
1711-
1712-
def convert_for_yaml(original_json: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
1713-
"""Convert the original JSON defined for JSON export into a JSON format more adapted for YAML export"""
1714-
clean_json = util.remove_nones(original_json)
1715-
new_json = []
1716-
for proj in util.dict_to_list(clean_json, "key"):
1717-
new_json.append(convert_proj_for_yaml(proj))
1718-
return new_json

sonar/qualitygates.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,3 @@ def _decode_condition(cond: str) -> tuple[str, str, str]:
561561
def search_by_name(endpoint: pf.Platform, name: str) -> dict[str, QualityGate]:
562562
"""Searches quality gates matching name"""
563563
return util.search_by_name(endpoint, name, QualityGate.API[c.LIST], "qualitygates")
564-
565-
566-
def convert_for_yaml(original_json: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
567-
"""Convert the original JSON defined for JSON export into a JSON format more adapted for YAML export"""
568-
return util.dict_to_list(util.remove_nones(original_json), "name")

sonar/qualityprofiles.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -917,14 +917,3 @@ def convert_one_qp_yaml(qp: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
917917
qp[_CHILDREN_KEY] = {k: convert_one_qp_yaml(q) for k, q in qp[_CHILDREN_KEY].items()}
918918
qp[_CHILDREN_KEY] = util.dict_to_list(qp[_CHILDREN_KEY], "name")
919919
return qp
920-
921-
922-
def convert_for_yaml(original_json: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
923-
"""Convert the original JSON defined for JSON export into a JSON format more adapted for YAML export"""
924-
new_json = {}
925-
for lang, qp_list in util.remove_nones(original_json).items():
926-
new_json[lang] = {"profiles": util.dict_to_list(qp_list, "name")}
927-
new_json = util.dict_to_list(new_json, "language")
928-
for lang in new_json:
929-
lang["profiles"] = [convert_one_qp_yaml(qp) for qp in lang["profiles"]]
930-
return new_json

sonar/rules.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,12 +562,6 @@ def convert_rule_list_for_yaml(rule_list: types.ObjectJsonRepr) -> list[types.Ob
562562
return utilities.dict_to_list(rule_list, "key", "severity")
563563

564564

565-
def convert_for_yaml(original_json: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
566-
"""Convert the original JSON defined for JSON export into a JSON format more adapted for YAML export"""
567-
clean_json = utilities.remove_nones(original_json)
568-
return {category: convert_rule_list_for_yaml(clean_json[category]) for category in ("instantiated", "extended") if category in clean_json}
569-
570-
571565
def third_party(endpoint: platform.Platform) -> list[Rule]:
572566
"""Returns the list of rules coming from 3rd party plugins"""
573567
return [r for r in get_list(endpoint=endpoint).values() if r.repo and r.repo not in SONAR_REPOS and not r.repo.startswith("external_")]

sonar/users.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,6 @@ def import_config(endpoint: pf.Platform, config_data: types.ObjectJsonRepr, key_
561561
o.update(**data)
562562

563563

564-
def convert_for_yaml(original_json: types.ObjectJsonRepr) -> types.ObjectJsonRepr:
565-
"""Convert the original JSON defined for JSON export into a JSON format more adapted for YAML export"""
566-
return util.dict_to_list(original_json, "login")
567-
568-
569564
def exists(endpoint: pf.Platform, login: str) -> bool:
570565
"""
571566
:param endpoint: reference to the SonarQube platform

0 commit comments

Comments
 (0)