|
|
|
@ -77,7 +77,7 @@ GLOBAL_STATUS = '*'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _assert_is_collection(obj):
|
|
|
|
|
assert not isinstance(obj, basestring)
|
|
|
|
|
assert not isinstance(obj, str)
|
|
|
|
|
# Module 'collections' has no 'Iterable' member
|
|
|
|
|
# pylint: disable=no-member
|
|
|
|
|
if hasattr(collections, 'Iterable') and hasattr(collections, 'Sized'):
|
|
|
|
@ -508,7 +508,7 @@ class Database(object):
|
|
|
|
|
# Now that we've used `owner` and covered all their dirs, remove them
|
|
|
|
|
# from consideration.
|
|
|
|
|
del all_possible_owners[owner]
|
|
|
|
|
for o, dirs in all_possible_owners.items():
|
|
|
|
|
for o, dirs in list(all_possible_owners.items()):
|
|
|
|
|
new_dirs = [(d, dist) for (d, dist) in dirs if d not in dirs_to_remove]
|
|
|
|
|
if not new_dirs:
|
|
|
|
|
del all_possible_owners[o]
|
|
|
|
@ -606,9 +606,9 @@ class Database(object):
|
|
|
|
|
dirs)
|
|
|
|
|
# Return the lowest cost owner. In the case of a tie, pick one randomly.
|
|
|
|
|
lowest_cost = min(total_costs_by_owner.values())
|
|
|
|
|
lowest_cost_owners = filter(
|
|
|
|
|
lambda owner: total_costs_by_owner[owner] == lowest_cost,
|
|
|
|
|
total_costs_by_owner)
|
|
|
|
|
lowest_cost_owners = [
|
|
|
|
|
owner for owner, cost in total_costs_by_owner.items()
|
|
|
|
|
if cost == lowest_cost]
|
|
|
|
|
return random.Random().choice(lowest_cost_owners)
|
|
|
|
|
|
|
|
|
|
def owners_rooted_at_file(self, filename):
|
|
|
|
|