ó ÿgdSc@sÚdZddlZedƒZddlmZddlmZmZej dkroddl m Z d „Z n4ej dkršddl m Z d „Z n ej Z d „Z d„Zded„Zd„Zd„ZdS(sÏ sphinx.util.inspect ~~~~~~~~~~~~~~~~~~~ Helpers for inspecting Python modules. :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. iÿÿÿÿNtinspect(t force_decode(tbytestbuiltinsii(tpartialc Csºtj|ƒr|j}nt|ƒtkrl|j}t|ƒ}t|dƒ}t|dpbd ƒ}t|dƒ}t|dpˆiƒ}|j r­|t |j ƒ}nx‹|j p¼d D]z}yC|j |ƒt |ƒ}||=y ||=Wnt k rnXWq½tk r6|j |ƒ}||=||=q½Xq½Wtj||d|dt|ƒ|||dƒSxt|dƒrŠ|j}qoWtj|ƒs­td |ƒ‚ntj|ƒS( s?Like inspect.getargspec but supports functools.partial as well.iiiiiiit __wrapped__s%r is not a Python function(((Rtismethodt__func__ttypeRtfunct getargspectlisttdicttargstlentkeywordstindext IndexErrort ValueErrort FullArgSpecttuplethasattrRt isfunctiont TypeErrortgetfullargspec( R t orig_functargspecR tdefaultstkwoargstkwodefstargti((s=/usr/local/lib/python2.7/site-packages/sphinx/util/inspect.pyR s>         iic Csštj|ƒr|j}nddf}t|ƒtkr~|j}|dkrWi}nt|jƒ|j ƒf}|j }ntj |ƒs t d|ƒ‚ntj |jƒ\}}}|j}|dkrÙg}n t|ƒ}|dr||d}n|draxT|dD]E}|j|ƒt|ƒ}||=y ||=Wqtk rYqXqWntjdkr†tj||||ƒS||||fSdS( s?Like inspect.getargspec but supports functools.partial as well.is%r is not a Python functioniiiN((ii(RRtim_funcRRRtNoneRR tkeysR RRtgetargst func_codet func_defaultsR RRtsyst version_infotArgSpec( R tpartsRR tvarargstvarkwR%RR((s=/usr/local/lib/python2.7/site-packages/sphinx/util/inspect.pyR <s:               cCs4x-dD]%}tt||dƒdƒrtSqWtS(s/Check if the object is some kind of descriptor.t__get__t__set__t __delete__t__call__(s__get__s__set__s __delete__N(Rt safe_getattrR!tTruetFalse(txtitem((s=/usr/local/lib/python2.7/site-packages/sphinx/util/inspect.pyt isdescriptoras cGsFyt|||ŒSWn+tk rA|r2|dSt|ƒ‚nXdS(s;A getattr() that turns all exceptions into AttributeErrors.iN(tgetattrt ExceptiontAttributeError(tobjtnametdefargs((s=/usr/local/lib/python2.7/site-packages/sphinx/util/inspect.pyR0is  cCsg}xjt|ƒD]\}y|||dƒ}Wntk rEqnX| sY||ƒr|j||fƒqqW|jƒ|S(s;A version of inspect.getmembers() that uses safe_getattr().N(tdirR!R8tappendtsort(tobjectt predicatet attr_gettertresultstkeytvalue((s=/usr/local/lib/python2.7/site-packages/sphinx/util/inspect.pytsafe_getmembersus  cCsbyt|ƒ}Wntk r)t‚nXt|tƒrRt|dƒjddƒS|jddƒS(sFA repr() implementation that returns text safe to use in reST context.s t N(treprR7Rt isinstanceRRR!treplace(R?ts((s=/usr/local/lib/python2.7/site-packages/sphinx/util/inspect.pyt safe_reprƒs  cCs…gtj|ƒD]}||jkr|^q}|rA|dnt}ttt|ddƒƒsftSttt|ddƒƒ|kS(sÿIf attr_name is implemented at builtin class, return True. >>> is_builtin_class_method(int, '__init__') True Why this function needed? CPython implements int.__init__ by Descriptor but PyPy implements it by pure Python code. it__name__t( Rtgetmrot__dict__R?RRR0R2R6(R9t attr_nametctclassestcls((s=/usr/local/lib/python2.7/site-packages/sphinx/util/inspect.pytis_builtin_class_methodŽs 1(ii(ii(t__doc__R&t __import__Rt sphinx.utilRtsphinx.util.pycompatRRR't functoolsRR R5R0R!RERKRT(((s=/usr/local/lib/python2.7/site-packages/sphinx/util/inspect.pyt s    " "