commit 9bb37cc3e7f541474f349d5f5f30fddb88b856d5 Author: Sathyanarayanan Gunasekaran gsathya.ceg@gmail.com Date: Mon Aug 20 13:53:55 2012 +0530
Iterate all relays over each filter
Previously all the filters were iterated over each relay. The order of the filter applied couldn't be controlled with this approach. Now, we can specify the order in which the relays are to be filtered in. --- compass.py | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/compass.py b/compass.py index 971b2e0..544306e 100755 --- a/compass.py +++ b/compass.py @@ -130,14 +130,12 @@ class RelayStats(object): return self._relays
self._relays = {} - for relay in self.data['relays']: - accepted = True - for f in self._filters: - if not f.accept(relay): - accepted = False - break - if accepted: - self.add_relay(relay) + relays = self.data['relays'] + for f in self._filters: + relays = filter(f.accept, relays) + + for relay in relays: + self.add_relay(relay) return self._relays
def _create_filters(self, options):
tor-commits@lists.torproject.org