def pad_release(release_to_pad, num_sections=4):
    '''
    Pad out package and kernel release versions so that
    ``LooseVersion`` comparisons will be correct.

    Release versions with less than num_sections will
    be padded in front of the last section with zeros.

    For example ::

        pad_release("390.el6", 4)

    will return ``390.0.0.el6`` and ::

        pad_release("390.11.el6", 4)

    will return ``390.11.0.el6``.

    If the number of sections of the release to be padded is
    greater than num_sections, a ``ValueError`` will be raised.
    '''
    parts = release_to_pad.split('.')

    if len(parts) > num_sections:
        raise ValueError("Too many sections encountered ({found} > {num} in release string {rel}".format(
            found=len(parts), num=num_sections, rel=release_to_pad
        ))

    pad_count = num_sections - len(parts)
    return ".".join(parts[:-1] + ['0'] * pad_count + parts[-1:])
Pad out package and kernel release versions so that
    ``LooseVersion`` comparisons will be correct.

    Release versions with less than num_sections will
    be padded in front of the last section with zeros.

    For example ::

        pad_release("390.el6", 4)

    will return ``390.0.0.el6`` and ::

        pad_release("390.11.el6", 4)

    will return ``390.11.0.el6``.

    If the number of sections of the release to be padded is
    greater than num_sections, a ``ValueError`` will be raised.