<s> """<STR_LIT>""" <EOL> from . import util , exc <EOL> _registrars = util . defaultdict ( list ) <EOL> def inspect ( subject , raiseerr = True ) : <EOL> """<STR_LIT>""" <EOL> type_ = type ( subject ) <EOL> for cls in type_ . __mro__ : <EOL> if cls in _registrars : <EOL> reg = _registrars [ cls ] <EOL> if reg is True : <EOL> return subject <EOL> ret = reg ( subject ) <EOL> if ret is not None : <EOL> break <EOL> else : <EOL> reg = ret = None <EOL> if raiseerr and ( <EOL> reg is None or ret is None <EOL> ) : <EOL> raise exc . NoInspectionAvailable ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> type_ ) <EOL> return ret <EOL> def _inspects ( * types ) : <EOL> def decorate ( fn_or_cls ) : <EOL> for type_ in types : <EOL> if type_ in _registrars : <EOL> raise AssertionError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % type_ ) <EOL> _registrars [ type_ ] = fn_or_cls <EOL> return fn_or_cls <EOL> return decorate <EOL> def _self_inspects ( cls ) : <EOL> _inspects ( cls ) ( True ) <EOL> return cls </s>
