Skip to content

Commit

Permalink
Json Dumps Implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
ashdriod committed Oct 13, 2023
1 parent 701ef2c commit 5ff1950
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions dtool_lookup_gui/views/config_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,10 @@ async def _retrieve_config(self):
buffer.set_text("") # Clearing the buffer
buffer.insert_at_cursor("\n".join(config_info))

def _format_server_config(self, server_config, indent=0):
"""Format the server configuration into a human-readable string representation."""
formatted_lines = []

if isinstance(server_config, dict):
for key, value in server_config.items():
if isinstance(value, dict):
formatted_lines.append(f"{key}:")
for inner_key, inner_value in value.items():
if isinstance(inner_value, dict):
formatted_lines.append(f"{inner_key}:")
for deep_key, deep_value in inner_value.items():
formatted_lines.append(f"{deep_key}:{deep_value}")
else:
formatted_lines.append(f"{inner_key}:{inner_value}")
else:
formatted_lines.append(f"{key}:{value}")

elif isinstance(server_config, list):
for item in server_config:
formatted_lines.append(f"- {item}")

else:
formatted_lines.append(str(server_config))

return formatted_lines
def _format_server_config(self, server_config):
"""Format the server configuration into a human-readable string representation using json.dumps."""
formatted_config = json.dumps(server_config, indent=4)
return formatted_config.splitlines()

@Gtk.Template.Callback()
def on_config_show(self, widget):
Expand Down

0 comments on commit 5ff1950

Please sign in to comment.