Browse code

Introduce output_data().

Xavier G authored on 26/04/2020 18:23:59
Showing 1 changed files

  • yamltab index 4b4266e..09001ab 100755
... ...
@@ -299,11 +299,16 @@ def keytab_data(buf, args):
299 299
 
300 300
 def keytab_to_yaml(buf, args):
301 301
 	keytab = keytab_data(buf, args)
302
-	final_keytab = prepare_serialization(keytab)
302
+	output_data(keytab, args, 0)
303
+
304
+def output_data(data, args, exit=None):
305
+	serialized_data = prepare_serialization(data)
303 306
 	if args.output_format == 'yaml':
304
-		yaml.dump(final_keytab, sys.stdout, width=160, sort_keys=False)
307
+		yaml.dump(serialized_data, sys.stdout, width=160, sort_keys=False)
305 308
 	else:
306
-		json.dump(final_keytab, sys.stdout, indent=4)
309
+		json.dump(serialized_data, sys.stdout, indent=4)
310
+	if exit is not None:
311
+		sys.exit(exit)
307 312
 
308 313
 def pack_data(data):
309 314
 	return struct.pack('>H', len(data)) + data