def get_shard(serial=None, salt=None, chunks=10):
    """
    get_shard(serial=None, salt=None, chunks=10)

    Returns the machine's unique shard number

    serial => Pass a serial for another machine to get its shard
    salt   => Pass a salt to generate the hash
    chunks => Pass an int to set number of chunks.
    """
    md5 = hashlib.md5()
    if not serial:
        serial = get_serial()
    if salt:
        serial = str(serial) + str(salt)
    md5.update(serial)
    digest = md5.hexdigest()
    number = int(digest, 16)
    shard = number % int(chunks)
    return shard
dataset/ETHPy150Open facebook/IT-CPE/code/lib/modules/sys_tools.py/get_shard/original