Skip to content

Refactor json_beau() with flexible indentation #25

@fhdk

Description

@fhdk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions