vici: Use OrderedDict to handle vici responses in Python library

The default Python dictionaries are unordered, but order is important for some
vici trees (for example the order of authentication rounds).
This commit is contained in:
Martin Willi
2015-03-18 13:59:14 +01:00
parent 94bb26fae3
commit 305023a27d
@@ -3,6 +3,7 @@ import socket
import struct
from collections import namedtuple
from collections import OrderedDict
from .exception import DeserializationException
@@ -150,13 +151,13 @@ class Message(object):
"Expected end of list at {pos}".format(pos=stream.tell())
)
section = {}
section = OrderedDict()
section_stack = []
while stream.has_more():
element_type, = struct.unpack("!B", stream.read(1))
if element_type == cls.SECTION_START:
section_name = decode_named_type(stream)
new_section = {}
new_section = OrderedDict()
section[section_name] = new_section
section_stack.append(section)
section = new_section