def make_formatter(format_name):
if "<STR_LIT>" in format_name:<EOL><INDENT>from json import dumps<EOL>import datetime<EOL>def jsonhandler(obj): obj.isoformat() if isinstance(obj, (datetime.datetime, datetime.date)) else obj<EOL>if format_name == "<STR_LIT>":<EOL><INDENT>def jsondumps(data): return dumps(data, default=jsonhandler, indent=<NUM_LIT:2>, separators=('<STR_LIT:U+002C>', '<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>def jsondumps(data): return dumps(data, default=jsonhandler)<EOL><DEDENT>def jsonify(data):<EOL><INDENT>if isinstance(data, dict):<EOL><INDENT>print(jsondumps(data))<EOL><DEDENT>elif isinstance(data, list):<EOL><INDENT>print(jsondumps([device._asdict() for device in data]))<EOL><DEDENT>else:<EOL><INDENT>print(dumps({'<STR_LIT:result>': data}))<EOL><DEDENT><DEDENT>return jsonify<EOL><DEDENT>else:<EOL><INDENT>def printer(data):<EOL><INDENT>if isinstance(data, dict):<EOL><INDENT>print(data)<EOL><DEDENT>else:<EOL><INDENT>for row in data:<EOL><INDENT>print(row)<EOL><DEDENT><DEDENT><DEDENT>return printer<EOL><DEDENT>
Returns a callable that outputs the data. Defaults to print.