def test_exclude_matches(self):
        exclude = Exclude()
        exclude.appendComponent(Name("%00%02").get(0))
        exclude.appendAny()
        exclude.appendComponent(Name("%00%20").get(0))

        component = Name("%00%01").get(0)
        self.assertFalse(exclude.matches(component),
          component.toEscapedString() + " should not match " + exclude.toUri())
        component = Name("%00%0F").get(0)
        self.assertTrue(exclude.matches(component),
          component.toEscapedString() + " should match " + exclude.toUri())
        component = Name("%00%21").get(0)
        self.assertFalse(exclude.matches(component),
          component.toEscapedString() + " should not match " + exclude.toUri())
Esempio n. 2
0
    def test_exclude_matches(self):
        exclude = Exclude()
        exclude.appendComponent(Name("%00%02").get(0))
        exclude.appendAny()
        exclude.appendComponent(Name("%00%20").get(0))

        component = Name("%00%01").get(0)
        self.assertFalse(exclude.matches(component),
          component.toEscapedString() + " should not match " + exclude.toUri())
        component = Name("%00%0F").get(0)
        self.assertTrue(exclude.matches(component),
          component.toEscapedString() + " should match " + exclude.toUri())
        component = Name("%00%21").get(0)
        self.assertFalse(exclude.matches(component),
          component.toEscapedString() + " should not match " + exclude.toUri())
Esempio n. 3
0
class PirStatus(object):
    def __init__(self):
        self._data = []
        self._exclude = Exclude()

    def addData(self, timestamp, value):
        if type(timestamp) is not long:
            return False
        if type(value) is not bool:
            return False
        if not any(x[0] == timestamp for x in self._data):
            self._data.append((timestamp, value))
            return True
        else:
            return False

    def getExclude(self):
        return self._exclude

    def setExcludeUpTo(self, exclude):
        self._exclude.clear()
        self._exclude.appendAny()
        self._exclude.appendComponent(exclude)

    def getLastValue(self):
        if len(self._data):
            return self._data[-1][1]
        else:
            return None

    def __repr__(self):
        return "PirStatus(data:{0}, exclude:'{1}')".format(
            self._data, self._exclude.toUri())
Esempio n. 4
0
class PirStatus(object):
    def __init__(self):
        self._data = []
        self._exclude = Exclude()
        
    def addData(self, timestamp, value):
        if type(timestamp) is not long:
            return False
        if type(value) is not bool:
            return False
        if not any(x[0] == timestamp for x in self._data):
            self._data.append((timestamp, value))
            return True
        else:
            return False

    def getExclude(self):
        return self._exclude

    def setExcludeUpTo(self, exclude):
        self._exclude.clear()
        self._exclude.appendAny()
        self._exclude.appendComponent(exclude)

    def getLastValue(self):
        if len(self._data):
            return self._data[-1][1]
        else:
            return None

    def __repr__(self):
        return "PirStatus(data:{0}, exclude:'{1}')".format(self._data, self._exclude.toUri())