python.d.plugin: OrderedDict import for python2.6 added
Ilya committed
Feb 18, 2017 at 14:52 UTC
33bdf00775ccafd6de5f208c74c78104e9fd7859
1 file changed
+10
-4
plugins.d/python.d.plugin
+10
-4
@@ -73,10 +73,16 @@ try:
73
DICT = OrderedDict
74
msg.info('YAML output is ordered')
75
except ImportError:
76
- ORDERED = False
77
- DICT = dict
78
- msg.info('YAML output is unordered')
79
-else:
76
+ try:
77
+ from ordereddict import OrderedDict
78
+ ORDERED = True
79
+ DICT = OrderedDict
80
+ msg.info('YAML output is ordered')
81
+ except ImportError:
82
+ ORDERED = False
83
+ DICT = dict
84
+ msg.info('YAML output is unordered')
85
+if ORDERED:
86
def ordered_load(stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict):
87
class OrderedLoader(Loader):
88
pass