Browse code

Introduce kvno_in_tail.

This extra property, shown only in full and simple modes, reflect whether
record tails are used to store 32-bit key version numbers.

Xavier G authored on 26/04/2020 16:31:20
Showing 1 changed files

  • yamltab index f61e444..567e6de 100755
... ...
@@ -225,7 +225,10 @@ def enrich_keytab(keytab):
225 225
 	"""
226 226
 	Enrich records with extra information suitable for human readers.
227 227
 	"""
228
-	for record in keytab['records']:
228
+	# Reflect whether the keytab uses record tails to store 32-bits kvno:
229
+	records = keytab.pop('records')
230
+	keytab['kvno_in_tail'] = False
231
+	for record in records:
229 232
 		if 'entry' not in record:
230 233
 			continue
231 234
 		entry = record['entry']
... ...
@@ -247,15 +250,18 @@ def enrich_keytab(keytab):
247 250
 					# tail_kvno overrides kvno if non-zero:
248 251
 					if entry['tail_kvno']:
249 252
 						entry['actual_kvno'] = entry['tail_kvno']
253
+						keytab['kvno_in_tail'] = True
250 254
 			if 'actual_kvno' not in entry:
251 255
 				entry['actual_kvno'] = entry['kvno']
256
+	# Reintroduce records after kvno_in_tail for convenience:
257
+	keytab['records'] = records
252 258
 	return keytab
253 259
 
254 260
 def simplify_keytab(keytab):
255 261
 	"""
256 262
 	Simplify the keytab to make it suitable for edition.
257 263
 	"""
258
-	simplified = {'version': keytab['version'], 'entries': []}
264
+	simplified = {'version': keytab['version'], 'kvno_in_tail': keytab['kvno_in_tail'], 'entries': []}
259 265
 	for record in keytab['records']:
260 266
 		if 'entry' not in record:
261 267
 			continue