manjaro / mdd

Manjaro Data Donor - WIP
MIT License
12 stars 3 forks source link

Refactor json_beau() with flexible indentation #25

Open fhdk opened 6 days ago

fhdk commented 6 days ago

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