@@ -129,7 +129,7 @@ def __repr__(self):
129129 return ret
130130
131131
132- class DOL (OrderedDict ):
132+ class DOL (list ):
133133 """Data Object List.
134134 This is sent by the card to the terminal to define a structure for
135135 future transactions, consisting of an ordered list of data elements and lengths.
@@ -148,12 +148,12 @@ def unmarshal(cls, data):
148148 i += tag_len
149149 length = data [i ]
150150 i += 1
151- dol [ Tag (tag )] = length
151+ dol . append (( Tag (tag ), length ))
152152 return dol
153153
154154 def size (self ):
155155 """Total size of the resulting structure in bytes."""
156- return sum (self . values () )
156+ return sum ([ val [ 1 ] for val in self ] )
157157
158158 def unserialise (self , data ):
159159 """Parse an input stream of bytes and return a TLV object."""
@@ -165,18 +165,24 @@ def unserialise(self, data):
165165
166166 tlv = TLV ()
167167 i = 0
168- for tag , length in self . items () :
168+ for tag , length in self :
169169 tlv [tag ] = data [i : i + length ]
170170 i += length
171171
172172 return tlv
173173
174+ def __contains__ (self , val ):
175+ for v in self :
176+ if v [0 ] == val :
177+ return True
178+ return False
179+
174180 def serialise (self , data ):
175181 """Given a dictionary of tag -> value, write this data out
176182 according to the DOL. Missing data will be null.
177183 """
178184 output = []
179- for tag , length in self . items () :
185+ for tag , length in self :
180186 value = data .get (tag , [0x0 ] * length )
181187 if len (value ) < length :
182188 # If the length is shorter than required, left-pad it.
0 commit comments