<s> """<STR_LIT>""" <EOL> from zope . interface . exceptions import BrokenImplementation , DoesNotImplement <EOL> from zope . interface . exceptions import BrokenMethodImplementation <EOL> from types import FunctionType , MethodType <EOL> from zope . interface . interface import fromMethod , fromFunction , Method <EOL> import sys <EOL> MethodTypes = ( MethodType , ) <EOL> def _verify ( iface , candidate , tentative = <NUM_LIT:0> , vtype = None ) : <EOL> """<STR_LIT>""" <EOL> if vtype == '<STR_LIT:c>' : <EOL> tester = iface . implementedBy <EOL> else : <EOL> tester = iface . providedBy <EOL> if not tentative and not tester ( candidate ) : <EOL> raise DoesNotImplement ( iface ) <EOL> for name , desc in iface . namesAndDescriptions ( <NUM_LIT:1> ) : <EOL> try : <EOL> attr = getattr ( candidate , name ) <EOL> except AttributeError : <EOL> if ( not isinstance ( desc , Method ) ) and vtype == '<STR_LIT:c>' : <EOL> continue <EOL> raise BrokenImplementation ( iface , name ) <EOL> if not isinstance ( desc , Method ) : <EOL> continue <EOL> if isinstance ( attr , FunctionType ) : <EOL> if sys . version [ <NUM_LIT:0> ] == '<STR_LIT:3>' and isinstance ( candidate , type ) : <EOL> meth = fromFunction ( attr , iface , name = name , <EOL> imlevel = <NUM_LIT:1> ) <EOL> else : <EOL> meth = fromFunction ( attr , iface , name = name ) <EOL> elif ( isinstance ( attr , MethodTypes ) <EOL> and type ( attr . __func__ ) is FunctionType ) : <EOL> meth = fromMethod ( attr , iface , name ) <EOL> else : <EOL> if not callable ( attr ) : <EOL> raise BrokenMethodImplementation ( name , "<STR_LIT>" ) <EOL> continue <EOL> desc = desc . getSignatureInfo ( ) <EOL> meth = meth . getSignatureInfo ( ) <EOL> mess = _incompat ( desc , meth ) <EOL> if mess : <EOL> raise BrokenMethodImplementation ( name , mess ) <EOL> return True <EOL> def verifyClass ( iface , candidate , tentative = <NUM_LIT:0> ) : <EOL> return _verify ( iface , candidate , tentative , vtype = '<STR_LIT:c>' ) <EOL> def verifyObject ( iface , candidate , tentative = <NUM_LIT:0> ) : <EOL> return _verify ( iface , candidate , tentative , vtype = '<STR_LIT:o>' ) <EOL> def _incompat ( required , implemented ) : <EOL> if len ( implemented [ '<STR_LIT>' ] ) > len ( required [ '<STR_LIT>' ] ) : <EOL> return '<STR_LIT>' <EOL> if ( ( len ( implemented [ '<STR_LIT>' ] ) < len ( required [ '<STR_LIT>' ] ) ) <EOL> and not implemented [ '<STR_LIT>' ] ) : <EOL> return "<STR_LIT>" <EOL> if required [ '<STR_LIT>' ] and not implemented [ '<STR_LIT>' ] : <EOL> return "<STR_LIT>" <EOL> if required [ '<STR_LIT>' ] and not implemented [ '<STR_LIT>' ] : <EOL> return "<STR_LIT>" </s>
