Example #1
0
    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
Example #2
0
    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')
Example #3
0
    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')
Example #4
0
    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
Example #5
0
 def removeIgnores(mask):
     for ignore in self.ignores:
         normalizedIgnore = util.normalizeMask(ignore)
         if not util.hostMatches(normalizedIgnore, mask):
             yield ignore
Example #6
0
 def addIgnore(self, mask):
     mask = util.normalizeMask(mask)
     if mask not in self.ignores:
         self.ignores = self.ignores + [mask]
         return mask
     return None