Skip to content

Commit

Permalink
Print result (#345)
Browse files Browse the repository at this point in the history
* Add support for OrderedDict to print_result()

* Add support for OrderedDict in print_result()
  • Loading branch information
Walter De Smedt authored and dbarrosop committed Mar 15, 2019
1 parent b17e537 commit 52e8795
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nornir/plugins/functions/text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import pprint
import threading
from typing import List, Optional, cast
from collections import OrderedDict
import json

from colorama import Fore, Style, init

Expand Down Expand Up @@ -61,7 +63,10 @@ def _print_individual_result(
# for consistency between py3.6 and py3.7
print(f"{x.__class__.__name__}{x.args}")
elif x and not isinstance(x, str):
pprint.pprint(x, indent=2)
if isinstance(x, OrderedDict):
print(json.dumps(x, indent=2))
else:
pprint.pprint(x, indent=2)
elif x:
print(x)

Expand Down

0 comments on commit 52e8795

Please sign in to comment.