Ejemplo n.º 1
0
def test_compat_callable():
    i = 1

    def f1():
        """docstring"""
        pass

    f2 = lambda x: x
    assert not _callable(i)

    assert _callable(f1)
    assert _callable(f2)
Ejemplo n.º 2
0
def test_compat_callable():
    i = 1

    def f1():
        """docstring"""
        pass

    f2 = lambda x: x
    assert not _callable(i)

    assert _callable(f1)
    assert _callable(f2)
    assert _func_name(f1) == 'f1'
    assert _func_doc(f1) == 'docstring'
Ejemplo n.º 3
0
def test_compat_callable():
    i = 1

    def f1():
        """docstring"""
        pass

    f2 = lambda x: x
    assert not _callable(i)

    assert _callable(f1)
    assert _callable(f2)
    assert _func_name(f1) == 'f1'
    assert _func_doc(f1) == 'docstring'
Ejemplo n.º 4
0
    def attach(self, subscriber):
        """
        Add a new subscriber.

        :param subscriber: a new object that implements the Subscriber object
            interface.
        """
        if hasattr(subscriber, 'update') and _callable(eval('subscriber.update')):
            if subscriber not in self.subscribers:
                self.subscribers.append(subscriber)
        else:
            raise TypeError('%r does not support required interface!' % subscriber)
Ejemplo n.º 5
0
    def attach(self, subscriber):
        """
        Add a new subscriber.

        :param subscriber: a new object that implements the Subscriber object
            interface.
        """
        if hasattr(subscriber, 'update') and _callable(subscriber.update):
            if subscriber not in self.subscribers:
                self.subscribers.append(subscriber)
        else:
            raise TypeError('%r does not support required interface!' % subscriber)
Ejemplo n.º 6
0
    def endElement(self, name):
        if self._is_active is True:
            if name == 'record' and self._tag_level == self._level:
                self._is_active = False
                self._tag_level = None
                if _callable(self._callback):
                    self._callback(self._record)
                self._record = None
            elif self._level == self._tag_level + 1:
                if name != 'xref':
                    self._record[name] = ''.join(self._tag_payload)
                    self._tag_payload = None
                    self._tag_feeding = False

        self._level -= 1