def leading_zeros(value, digits):
    """ Pads value with leading zeros, given by digits. """
    try:
        value = str(value)
        for i in range(0, int(digits) - len(value)):
            value = "0" + value
        return value
    except:
        return ""