|
64 | 64 | } |
65 | 65 |
|
66 | 66 | _EXPORT_CALLS = { |
67 | | - c.CONFIG_KEY_PLATFORM: [c.CONFIG_KEY_PLATFORM, platform.basics, platform.convert_for_yaml], |
68 | | - options.WHAT_SETTINGS: [c.CONFIG_KEY_SETTINGS, platform.export, platform.convert_for_yaml], |
69 | | - options.WHAT_RULES: [c.CONFIG_KEY_RULES, rules.export, rules.convert_for_yaml], |
70 | | - options.WHAT_PROFILES: [c.CONFIG_KEY_PROFILES, qualityprofiles.export, qualityprofiles.convert_for_yaml], |
71 | | - options.WHAT_GATES: [c.CONFIG_KEY_GATES, qualitygates.export, qualitygates.convert_for_yaml], |
72 | | - options.WHAT_PROJECTS: [c.CONFIG_KEY_PROJECTS, projects.export, projects.convert_for_yaml], |
73 | | - options.WHAT_APPS: [c.CONFIG_KEY_APPS, applications.export, applications.convert_for_yaml], |
74 | | - options.WHAT_PORTFOLIOS: [c.CONFIG_KEY_PORTFOLIOS, portfolios.export, portfolios.convert_for_yaml], |
75 | | - options.WHAT_USERS: [c.CONFIG_KEY_USERS, users.export, users.convert_for_yaml], |
76 | | - options.WHAT_GROUPS: [c.CONFIG_KEY_GROUPS, groups.export, groups.convert_for_yaml], |
| 67 | + c.CONFIG_KEY_PLATFORM: [c.CONFIG_KEY_PLATFORM, platform.basics], |
| 68 | + options.WHAT_SETTINGS: [c.CONFIG_KEY_SETTINGS, platform.export], |
| 69 | + options.WHAT_RULES: [c.CONFIG_KEY_RULES, rules.export], |
| 70 | + options.WHAT_PROFILES: [c.CONFIG_KEY_PROFILES, qualityprofiles.export], |
| 71 | + options.WHAT_GATES: [c.CONFIG_KEY_GATES, qualitygates.export], |
| 72 | + options.WHAT_PROJECTS: [c.CONFIG_KEY_PROJECTS, projects.export], |
| 73 | + options.WHAT_APPS: [c.CONFIG_KEY_APPS, applications.export], |
| 74 | + options.WHAT_PORTFOLIOS: [c.CONFIG_KEY_PORTFOLIOS, portfolios.export], |
| 75 | + options.WHAT_USERS: [c.CONFIG_KEY_USERS, users.export], |
| 76 | + options.WHAT_GROUPS: [c.CONFIG_KEY_GROUPS, groups.export], |
77 | 77 | } |
78 | 78 |
|
79 | 79 | WHAT_EVERYTHING = list(_EXPORT_CALLS.keys())[1:] |
@@ -150,22 +150,12 @@ def __normalize_file(file: str, format: str) -> bool: |
150 | 150 | json_data = __normalize_json(json_data, remove_empty=False, remove_none=True) |
151 | 151 | with utilities.open_file(file, mode="w") as fd: |
152 | 152 | if format == "yaml": |
153 | | - print(yaml.dump(__convert_for_yaml(json_data), sort_keys=False), file=fd) |
| 153 | + print(yaml.dump(json_data, sort_keys=False), file=fd) |
154 | 154 | else: |
155 | 155 | print(utilities.json_dump(json_data), file=fd) |
156 | 156 | return True |
157 | 157 |
|
158 | 158 |
|
159 | | -def __convert_for_yaml(json_export: dict[str, any]) -> dict[str, any]: |
160 | | - """Converts the default JSON produced by export to a modified version more suitable for YAML""" |
161 | | - for what in WHAT_EVERYTHING: |
162 | | - for k in json_export: |
163 | | - if what.lower() == k.lower() or (what == "settings" and k == "globalSettings"): |
164 | | - yamlify_func = _EXPORT_CALLS[what][2] |
165 | | - json_export[k] = yamlify_func(json_export[k]) |
166 | | - return json_export |
167 | | - |
168 | | - |
169 | 159 | def write_objects(queue: Queue[types.ObjectJsonRepr], fd: TextIO, object_type: str, export_settings: types.ConfigSettings) -> None: |
170 | 160 | """ |
171 | 161 | Thread to write projects in the JSON file |
@@ -234,7 +224,7 @@ def export_config(endpoint: platform.Platform, what: list[str], **kwargs) -> Non |
234 | 224 | for what_item, call_data in _EXPORT_CALLS.items(): |
235 | 225 | if what_item not in what: |
236 | 226 | continue |
237 | | - ndx, func, _ = call_data |
| 227 | + ndx, func = call_data |
238 | 228 | if not is_first: |
239 | 229 | print(",", file=fd) |
240 | 230 | is_first = False |
|
0 commit comments