L i6dZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z dZ ejde Zd Zd Zdd Zd Zd ZdefdZdZdZddZy)z> My own variation on function-specific inspect-like features. N)islice)open)pformatzAargs varargs varkw defaults kwonlyargs kwonlydefaults annotations FullArgSpeccd} |j}|j}tjj |svdj t j|d}d}|jdr7tjd|j\}}t|}d|z}|||fSt|5}|j}tt!||dz d}ddddj t j"|fS#1swY0xYw#t%|dr(t'|jj)|d fcYSt+||d fcYSxYw) a/Attempts to retrieve a reliable function code hash. The reason we don't use inspect.getsource is that it caches the source, whereas we want this to be modified on the fly when the function is modified. Returns ------- func_code: string The function code source_file: string The path to the file in which the function is defined. first_line: int The first line of the code in the source file. Notes ------ This function does a bit more magic than inspect, and is thus more robust. Nrrz z __code__)r co_filenameospathexistsjoininspectgetsourcelines startswithrematchgroupsintopen_py_sourceco_firstlinenolistrgetblockhasattrstr__hash__repr)func source_filecode source_codeline_nosource_file_obj first_line source_liness Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/joblib/func_inspect.py get_func_coder)sT*K /}}&& ww~~k*'''"8"8">q"ABKG%%k2')xx4k(&(% Wg,,{:  W4 4 K ( OO,,J Q MNL Owww'' 56 ZOO  O O / 4 $t}}--/0+rA A :{B. .s0B,D1 D<&D".DDD4E#E#cddl}t|dr |j}nddl}|jj}dD]}|j |||}|S)z2Windows cannot encode some characters in filename.rNquote)<>!:\)urllibrr+ urllib.parseparsereplace)stringr1r+chars r(_clean_win_charsr7RsTvw   ""*3eDk23 Mc`t|dr |j}n tj|}|d}|dk(r t jjtj|}||jt j}|djdr2|djd }d j|dd |d dz|d<n't|d kDr|d jd rd|d <d j|}|jdr|dd}|d z|z}|jd}t|dr |j }nt|dr |j"}nd}|r0t|dr$||j$vr|j$||urd|z}t|dr<|j&|k7r-|j)|j&jdddtj*|r3t|dr'|j,}|j/|j"t j0dk(r%|r#t3|}|D cgc] } t3| }} ||fS#t$r)t|dr|j j}nd}YmwxYw#d}Y%/56!"1%66 4<I #t[)22"  # Hn7s"I,2J!J+,.JJ!J(c&dj||S)z.Helper function to output a function signaturez{}{})format) function_namearg_sigs r(_signature_strrds == 00r8cd}t|dd}djd|jD}|j|||S)z)Helper function to output a function callz {0}({1}, {2})rr , c30K|]\}}|d|yw)=N).0kvs r( z'_function_called_str..sG1a+Gs)rritemsra)rbargskwargs template_strargs_str kwargs_strs r(_function_called_strrtsF"LDz!BHG GGJ   }h CCr8ric <t|}t|trtd|dt |dt j |s6t j|s!|rtjd|zd||dSt j|}g}g}g}d}d} |jjD]} | j| jur|j| j n| j| j"ur7|j| j |j| j nI| j| j$ur | j }n$| j| j&ur | j } | j(| j*us|j| j(t j |rS|j,g|z}t j|j.} t1t3| j} | g|z}t5|d \} }t7}d }t9|D]n\}}|t;|kr7||vr ||||<!td |d t=||dt?|||d|t;|z }||vr ||||<f ||||<pt7}tE|jGD](\}}||vr|||<| |||<tId|d|d| ||d<| ||dzd}||d<|D]2}||vr|jK|td|dt=|||S#t@tBf$r-}tdt=||dt?|||d|d}~wwxYw)aXFilters the given args and kwargs using a list of arguments to ignore, and a function specification. Parameters ---------- func: callable Function giving the argument specification ignore_lst: list of strings List of arguments to ignore (either a name of an argument in the function spec, or '*', or '**') *args: list Positional arguments passed to the function. **kwargs: dict Keyword arguments passed to the function Returns ------- filtered_args: list List of filtered positional and keyword arguments. z2ignore_lst must be a list of parameters to ignore z (type z ) was givenz4Cannot inspect object %s, ignore list will not work.r?) stacklevel)***NF)rXr zKeyword-only parameter 'z)' was passed as positional parameter for z: z was called.zWrong number of arguments for zIgnore list for z,() contains an unexpected keyword argument ''rxrrwzIgnore list: argument 'z' is not defined for function )&r isinstancer ValueErrortyperrU isfunctionwarningswarn signature parametersvalueskindPOSITIONAL_OR_KEYWORDrVrW KEYWORD_ONLYVAR_POSITIONAL VAR_KEYWORDdefaultempty__self____func__nextiterr_dict enumeraterRrdrt IndexErrorKeyErrorsortedrnrMpop)r ignore_lstrorprc arg_names arg_defaultsarg_kwonlyargs arg_varargs arg_varkwparamclass_method_sig self_name_rWarg_dict arg_positionarg_namepositione varkwargs arg_valuevarargsitems r( filter_argsrs* :D*c"(2D4D F    D !'*<*rs +H+K**=:MN6/r  Wt1 D(*$&GT"0r8