def write_padding ( fp , size , divisor = 2 ) : remainder = size % divisor if remainder : return write_bytes ( fp , struct . pack ( '%dx' % ( divisor - remainder ) ) ) return 0
python increase file size padding
Writes padding bytes given the currently written size .
def write_padding(fp, size, divisor=2):
    """
    Writes padding bytes given the currently written size.

    :param fp: file-like object
    :param divisor: divisor of the byte alignment
    :return: written byte size
    """
    remainder = size % divisor
    if remainder:
        return write_bytes(fp, struct.pack('%dx' % (divisor - remainder)))
    return 0