Generating the reconstructed alignment from BAM
If all you want are the number of insertions/deletions, you can use this to extract that info:

from cigar import Cigar
c = c=Cigar('20M5I10M3I5M')
num_insertions = len(list(filter(lambda x: x[1] == 'I', c.items())))
insertion_length = sum([x[0] for x in list(filter(lambda x: x[1] == 'I', c.items()))])


Deletions would be the same thing with 'D' in place of 'I'