Ejemplo n.º 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
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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
Ejemplo n.º 5
0
 def removeIgnores(mask):
     for ignore in self.ignores:
         normalizedIgnore = util.normalizeMask(ignore)
         if not util.hostMatches(normalizedIgnore, mask):
             yield ignore
Ejemplo n.º 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