def isIgnored(self, mask): mask = util.normalizeMask(mask) for ignore in self.ignores: ignore = util.normalizeMask(ignore) if util.hostMatches(mask, ignore): return True return False
def test_normalizeMask(self): """ Normalizing a mask with L{eridanus.util.normalizeMask} results in a normalized mask that successfully represents the input. """ self.assertEqual(util.normalizeMask('bob'), 'bob!*@*') self.assertEqual(util.normalizeMask('bob!foo'), 'bob!foo@*') self.assertEqual(util.normalizeMask('bob!foo@bar'), 'bob!foo@bar') self.assertRaises(errors.InvalidMaskError, util.normalizeMask, '') self.assertRaises(errors.InvalidMaskError, util.normalizeMask, 'bob@bar') self.assertRaises(errors.InvalidMaskError, util.normalizeMask, 'bob@foo!bar')
def removeIgnore(self, mask): def removeIgnores(mask): for ignore in self.ignores: normalizedIgnore = util.normalizeMask(ignore) if not util.hostMatches(normalizedIgnore, mask): yield ignore mask = util.normalizeMask(mask) newIgnores = list(removeIgnores(mask)) diff = set(self.ignores) - set(newIgnores) self.ignores = newIgnores return list(diff) or None
def removeIgnores(mask): for ignore in self.ignores: normalizedIgnore = util.normalizeMask(ignore) if not util.hostMatches(normalizedIgnore, mask): yield ignore
def addIgnore(self, mask): mask = util.normalizeMask(mask) if mask not in self.ignores: self.ignores = self.ignores + [mask] return mask return None