def get_index_bucket(oval_id):
    """The current repository schema protects against having too many files in a single directory by
    creating subdirectories based on the index portion of the OVALID that limits the number of
    files to 1000.  This function determines the proper bucket based on the OVALID
    @type oval_id: string
    @param oval_id: The OVALID
    
    @rtype: int
    @return: an integer representing the proper subdirectory for this OVALID, or 0 if it could not
    be computed.  
    """
    if not oval_id or oval_id is None:
        return None
        
    # Get the numeric index from the end of the OVAL ID
    position = oval_id.rfind(':')
    if position < 0:
        return None
        
    try:
        position = position + 1
        index = int(oval_id[position:])

        if index < 1000:
            return "0000"

        # Apply the modulus function to determine which bucket it belongs to
        return str(int(index/1000) * 1000)
        # Or another way to do it:
#             sequence = int(index)
#             mod = sequence % 1000
#             return sequence - mod + 1000
    except Exception:
        return None