def test_compat_callable(): i = 1 def f1(): """docstring""" pass f2 = lambda x: x assert not _callable(i) assert _callable(f1) assert _callable(f2)
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'
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)
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)
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