def _can_steal(thief, ts, victim):
    'Determine whether worker ``thief`` can steal task ``ts`` from worker\n    ``victim``.\n\n    Assumes that `ts` has some restrictions.\n    '
    if (ts.host_restrictions and (get_address_host(thief.address) not in ts.host_restrictions)):
        return False
    elif (ts.worker_restrictions and (thief.address not in ts.worker_restrictions)):
        return False
    if (victim.resources is None):
        return True
    for (resource, value) in victim.resources.items():
        try:
            supplied = thief.resources[resource]
        except KeyError:
            return False
        else:
            if (supplied < value):
                return False
    return True
Determine whether worker ``thief`` can steal task ``ts`` from worker
``victim``.

Assumes that `ts` has some restrictions.
def _can_steal(thief, ts, victim):
    'Determine whether worker ``thief`` can steal task ``ts`` from worker\n    ``victim``.\n\n    Assumes that `ts` has some restrictions.\n    '
    if (ts.host_restrictions and (get_address_host(thief.address) not in ts.host_restrictions)):
        return False
    elif (ts.worker_restrictions and (thief.address not in ts.worker_restrictions)):
        return False
    if (victim.resources is None):
        return True
    for (resource, value) in victim.resources.items():
        try:
            supplied = thief.resources[resource]
        except KeyError:
            return False
        else:
            if (supplied < value):
                return False
    return True