Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor json_beau() with flexible indentation #25

Open
fhdk opened this issue Nov 16, 2024 · 0 comments
Open

Refactor json_beau() with flexible indentation #25

fhdk opened this issue Nov 16, 2024 · 0 comments

Comments

@fhdk
Copy link
Member

fhdk commented Nov 16, 2024

A hardcoded 4 space can look awkward - so adding an indentation property defaulting to 4 makes it possible to use another value in the call.

diff --git a/mdd.py b/mdd.py
index cb9f3c1..cfb1de8 100644
--- a/mdd.py
+++ b/mdd.py
@@ -24,8 +24,8 @@ from dateutil import parser as date_parser
 inxi = None
 
 
-def json_beaut(input, sort_keys=False):
-    return json.dumps(input, indent=4, sort_keys=sort_keys)
+def json_beaut(input, sort_keys=False, indent=4):
+    return json.dumps(input, indent=indent, sort_keys=sort_keys)
 
 
 def prepare_inxi():

refactor-to-flexible-json-indent.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant