def checkURI(self): p = protocolForURI("http://www.python.org/") assert p is not IProtocol1 p = protocolForURI("http://peak.telecommunity.com/PyProtocols") assert p is IProtocol1
class IConnectCallable(protocols.Interface): protocols.advise(equivalentProtocols = [protocols.protocolForURI("http://www.dotsyntax.com/protocols/connectcallable")]) def __call__(callable): pass
assert a2 is not a assert a2.subject is n assert adapt(n, I) is a2 from protocols import protocolForType, protocolForURI, sequenceOf, advise from protocols import declareImplementation, Variation from UserDict import UserDict IGetSetMapping = protocolForType(dict, ["__getitem__", "__setitem__"]) IGetMapping = protocolForType(dict, ["__getitem__"]) ISimpleReadFile = protocolForType(file, ["read"]) IImplicitRead = protocolForType(file, ["read"], implicit=True) IProtocol1 = protocolForURI("http://peak.telecommunity.com/PyProtocols") multimap = sequenceOf(IGetMapping) declareImplementation(UserDict, [IGetSetMapping]) IMyUnusualMapping = Variation(IGetSetMapping) class MyUserMapping(object): pass declareImplementation(MyUserMapping, [IMyUnusualMapping])
show = property(__get_show, __set_show) def set_message(self, message, status, format=None, default_status='normal'): return super(FaceBookChatXMPP, self).set_message(message = None, status = '', format = format, default_status = \ default_status) def do_call(callable): callable() def get_call_wrapper(*a, **k): return do_call #we've got some stuff to do before the actual socket.connect, so we'll be #responsible for what thread things are on, not jabber import protocols protocols.declareAdapterForType( protocols.protocolForURI( "http://www.dotsyntax.com/protocols/connectcallable"), get_call_wrapper, FaceBookChatXMPP)
assert a2 is not a assert a2.subject is n assert adapt(n, I) is a2 from protocols import protocolForType, protocolForURI, sequenceOf, advise from protocols import declareImplementation, Variation from UserDict import UserDict IGetSetMapping = protocolForType(dict, ['__getitem__', '__setitem__']) IGetMapping = protocolForType(dict, ['__getitem__']) ISimpleReadFile = protocolForType(file, ['read']) IImplicitRead = protocolForType(file, ['read'], implicit=True) IProtocol1 = protocolForURI("http://peak.telecommunity.com/PyProtocols") multimap = sequenceOf(IGetMapping) declareImplementation(UserDict, [IGetSetMapping]) IMyUnusualMapping = Variation(IGetSetMapping) class MyUserMapping(object): pass declareImplementation(MyUserMapping, [IMyUnusualMapping])
def __set_show(self, state): pass def __get_show(self): if self._idle: return 'away' else: return None show = property(__get_show, __set_show) def set_message(self, message, status, format = None, default_status='normal'): return super(FaceBookChatXMPP, self).set_message(message = None, status = '', format = format, default_status = \ default_status) def do_call(callable): callable() def get_call_wrapper(*a, **k): return do_call #we've got some stuff to do before the actual socket.connect, so we'll be #responsible for what thread things are on, not jabber import protocols protocols.declareAdapterForType(protocols.protocolForURI("http://www.dotsyntax.com/protocols/connectcallable"), get_call_wrapper, FaceBookChatXMPP)