def clone(): """Return a simple generic function that "inherits" from this one""" f = _mkGeneric(oldfunc,argname) protocols.declareAdapter( protocols.NO_ADAPTER_NEEDED,[f.protocol],forProtocols=[protocol] ) return f
def checkImplicationBug(self): class I1(Interface): pass class I2(I1): pass declareAdapter(lambda o: o, provides=[I1], forProtocols=[I2])
def clone(): """Return a simple generic function that "inherits" from this one""" f = _mkGeneric(oldfunc, argname) protocols.declareAdapter(protocols.NO_ADAPTER_NEEDED, [f.protocol], forProtocols=[protocol]) return f
def declareForProto(pro, proto, factory): protocols.declareAdapter(factory, provides=[proto], forProtocols=[pro])
def declareForType(typ, proto, factory): protocols.declareAdapter(factory, provides=[proto], forTypes=[typ])
def declareForProto(pro,proto,factory): protocols.declareAdapter(factory,provides=[proto],forProtocols=[pro])
def declareForType(typ,proto,factory): protocols.declareAdapter(factory,provides=[proto],forTypes=[typ])
return self.items[0] | sig return Predicate(self.items + [sig]) return Predicate(list(self) + list(other)) def __eq__(self, other): return self is other or self.items == list(other) def __ne__(self, other): return not self.__eq__(other) def __repr__(self): return repr(self.items) protocols.declareAdapter(lambda ob: Predicate([ob]), [IDispatchPredicate], forProtocols=[ISignature]) class Signature(object): """A set of criteria (in conjunctive normal form) applied to expressions""" protocols.advise(instancesProvide=[ISignature]) __slots__ = 'data', 'keys' def __init__(self, __id_to_test=(), **kw): items = list(__id_to_test) + [(Argument(name=k), v) for k, v in list(kw.items())] self.data = data = {} self.keys = keys = [] for k, v in items:
return self.items[0] | sig return Predicate(self.items+[sig]) return Predicate(list(self)+list(other)) def __eq__(self,other): return self is other or self.items==list(other) def __ne__(self,other): return not self.__eq__(other) def __repr__(self): return repr(self.items) protocols.declareAdapter( lambda ob: Predicate([ob]), [IDispatchPredicate], forProtocols=[ISignature] ) class Signature(object): """A set of criteria (in conjunctive normal form) applied to expressions""" protocols.advise(instancesProvide=[ISignature]) __slots__ = 'data','keys' def __init__(self, __id_to_test=(), **kw): items = list(__id_to_test)+[(Argument(name=k),v) for k,v in list(kw.items())] self.data = data = {}; self.keys = keys = [] for k,v in items: v = ICriterion(v) k = k,v.node_type
"""Parse 'input' at 'startState', call 'produce(result)', return state Return a 'ParseError' instance if no match""" def format(data, write): """Pass formatted 'data' to 'write()'""" def withTerminators(terminators, memo): """Return a version of this syntax using the specified terminators""" def getOpening(closing, memo): """Possible opening characters for this match, based on 'closing'""" protocols.declareAdapter(lambda o: Optional(*o), provides=[IRule], forTypes=[tuple]) class Rule(object): """Production rule protocol for translation between data and strings""" protocols.advise(instancesProvide=[IRule]) __slots__ = () def parse(self, input, produce, startState): raise NotImplementedError def format(self, data, write): raise NotImplementedError