OwlCyberSecurity - MANAGER
Edit File: decorator.cpython-36.pyc
3 5*[Z�@������������������@���s���d�Z�ddlmZ�ddlZddlZddlZddlZddlZddlZdZ ej dkrdddlmZ�dd��Znej d d �Zdd��Zd d��Zy ejZW�n�ek r����dd��ZY�nX�ej dd�Zdd��Zejd�ZG�dd��de�Zf�fdd�Zd*dd�ZyddlmZ�W�n"�ek �r���ddlmZ�Y�nX�G�dd��de�Zeej�Ze ej!�Z"e"dk�rhej#��rhd d!��Zee_n,e"dk�r|ej#�r|ne"d"k�r�d#d!��Zee_ee�Z$d$d%��Z%d&d'��Z&d(d)��Z'dS�)+zT Decorator module, see http://pypi.python.org/pypi/decorator for the documentation. �����)�print_functionNz4.2.1�3)�getfullargspecc�������������C���s���|�j�S�)N)�__init__)�cls��r����/usr/lib/python3.6/decorator.py�get_init0���s����r ����FullArgSpecz5args varargs varkw defaults kwonlyargs kwonlydefaultsc�������������C���s���t�jtj|��g�df��S�)z?A quick and dirty replacement for getfullargspec for Python 2.XN)r ����_make�inspect� getargspec)�fr���r���r���r���7���s����r���c�������������C���s���|�j�jS�)N)r����__func__)r���r���r���r���r ���;���s����c�������������C���s���dS�)NFr���)r���r���r���r����iscoroutinefunctionB���s����r����ArgSpeczargs varargs varkw defaultsc�������������C���s���t�|��}t|j|j|j|j�S�)z$A replacement for inspect.getargspec)r���r����args�varargs�varkw�defaults)r����specr���r���r���r ���J���s����r ���z\s*def\s*([_\w][_\w\d]*)\s*\(c���������������@���sZ���e�Zd�ZdZej��Zf��Z�Z�Z �Z �ZZd dd�Z dd��Zddd �Zeddd��ZdS�)� FunctionMakerz� An object with the ability to create functions with a given signature. It has attributes name, doc, module, signature, defaults, dict and methods update and make. Nc�������������C���s���||�_�|�rf|j|�_|�jdkr$d|�_|j|�_|j|�_tj|��rft |�}t |di��|�_xdD�]} t|�| t || ���q\W�x&t |�j�D�]\} }t|�d | �|��q�W�t|�j�}t|�j�} |�jr�|jd|�j���| jd|�j���n|�jr�|jd��x.|�jD�]$} |jd| ���| jd | | f���q�W�|�j�rB|jd|�j���| jd|�j���dj|�|�_dj| �|�_�|jj��|�_|�rr||�_|d�k �r�||�_|�r�||�_|�r�||�_|�r�||�_|�r�||�_t|�d��s�t�t|�d��s�td|���d�S�)Nz<lambda>�_lambda_�__annotations__r���r���r���r���� kwonlyargs�kwonlydefaultszarg%d�*z%s=Nonez%s=%sz**z, �name� signaturez%You are decorating a non function: %s)r���r���r���r���r���r���)�shortsignature�__name__r����__doc__�doc� __module__�moduler���� isfunctionr����getattr�annotations�setattr� enumerater����listr����appendr���r����joinr����__dict__�copy�dictr����hasattr�AssertionError� TypeError)�self�funcr���r���r���r"���r$���ZfuncdictZargspec�a�i�argZallargsZallshortargsr���r���r���r���a���s\���� zFunctionMaker.__init__c�������������K���s����|�j�|_t|�dd�|_t|�di��|_|�j|_|�jp4d|_t|�dd�|_ yt jd�}W�n�tk rl���d}Y�nX�|j jdd�}t|�d|�|_|jj|��dS�) z2Update the signature of func with the data in selfr"���Nr/���r'��������?r ���r$���)r���r ���r&���r!���r-���r����__defaults__r����__kwdefaults__r����sys� _getframe�AttributeError� f_globals�getr#����update)r3���r4����kw�frameZcallermoduler���r���r���rA�������s���� zFunctionMaker.updateFc������� ��� ���K���s��|t�|���}|pi�}tj|�}|dkr2td|���|jd�}t|gdd��|�jjd�D����}x$|D�]} | dkrbtd | |f���qbW�|j d �s�|d 7�}dt |�j�f�} yt|| d�}t ||��W�n*���td tjd��t|tjd����Y�nX�||�}|�r�||d<�|�j|f|��|S�)zBMake a new function from a given template and update the signatureNz not a valid function template %s����c�������������S���s���g�|�]}|j�d���qS�)z *)�strip)�.0r7���r���r���r���� <listcomp>����s����z&FunctionMaker.make.<locals>.<listcomp>�,�_func_�_call_z%s is overridden in %s� z<decorator-gen-%d>ZsinglezError in generated code:)�fileZ __source__)rI���rJ���)�vars�DEF�search�SyntaxError�group�setr����split� NameError�endswith�next�_compile_count�compile�exec�printr<����stderrrA���) r3���Z src_templ�evaldict� addsource�attrs�src�mor����names�n�filename�coder4���r���r���r����make����s4���� zFunctionMaker.makeTc�������������K���s����t�|t�r0|j��jdd�\} } | dd��}d}nd} d}|}|�|| ||||�} djdd��|j��D���}|jd�}|r�t|�r�d|�jd d �}nd|�}| j |||f|�S�) z� Create a function from the strings name, signature and body. evaldict is the evaluation dictionary. If addsource is true an attribute __source__ is added to the result. The attributes attrs are added, if any. �(rD���NrK���c�������������s���s���|�]}d�|�V��qdS�)z Nr���)rF����liner���r���r���� <genexpr>����s����z'FunctionMaker.create.<locals>.<genexpr>rJ���z#async def %(name)s(%(signature)s): �returnzreturn awaitzdef %(name)s(%(signature)s): ���) � isinstance�strrE���rS���r,���� splitlinesr@���r����replacere���)r����objZbodyr\���r���r"���r$���r]���r^���r����restr���r4���r3���Zibody�callerr���r���r����create����s���� zFunctionMaker.create)NNNNNNN)NF)NNNT)r ���r#����__qualname__r!���� itertools�countrW���r���r���r���r���r���r���r���rA���re����classmethodrr���r���r���r���r���r���T���s���� 3 "�r���c������� ������C���sn���t�||�d�}d}x0t|�D�]$\}}d|�}|||<�||d�7�}qW�tj|�d|�||�d�}t|�d�rj|�j|_|S�)zE decorate(func, caller) decorates a function using a caller. )rJ���rI�����z_e%d_z, z,return _call_(_func_, %s%%(shortsignature)s))�__wrapped__rs���)r/���r)���r���rr���r0���rs���) r4���rq���Zextrasr\���Zesr6���ZextraZexZfunr���r���r����decorate����s���� ry���c������� ������C���s��|dk rt�||��S�df��}}tj|��rB|�jj��}d|�j|�jf�}n~tj|��r�|�jdkr\d}n|�j}|�j}|�jj}t |�j pzf��}dj|�jj||�|���}|r�|d7�}|�j }n|�j jj��}|�jj}t|�t�d�}tjd ||f�d ||f�|||�j|�d�} |�rd|�| _ | S�) z=decorator(caller) converts a caller function into a decoratorNrw���zHdecorator(%s) converts functions/generators into factories of %s objectsz<lambda>r���z, rH���)�_callZ _decorate_z%s(func, %s)zhif func is None: return lambda func: _decorate_(func, _call, (%s)) return _decorate_(func, _call, (%s)))r"���r$���rx���)N)ry���r���Zisclassr ����lowerr%���r!����__code__�co_argcount�lenr:���r,����co_varnames� __class__�__call__r/���r���rr���r#���) rq���Z_funcZdefaultargsr���r���r"����nargsZndefsr\����decr���r���r���� decorator����s:���� r����)�_GeneratorContextManager)�GeneratorContextManagerc���������������@���s���e�Zd�Zdd��ZdS�)�ContextManagerc�������������C���s���t�j|dt|�|d�|d�S�)zContext manager decoratorz.with _self_: return _func_(%(shortsignature)s))Z_self_rI���)rx���)r���rr���r/���)r3���r4���r���r���r���r����#��s����zContextManager.__call__N)r ���r#���rs���r����r���r���r���r���r����"��s���r��������c�������������O���s���t�j|�|||��S�)N)r����r���)r3����gr5����kr���r���r���r���-��s����r�������c�������������O���s���t�j|�|||�S�)N)r����r���)r3���r����r5���r����r���r���r���r���3��s����c�������������C���s���t�|��S�)N)�_contextmanager)r4���r���r���r����contextmanager:��s����r����c�������������C���sR���d}x:t�|�D�].\}}t||��r&d}P�t|�|�r|�||<�d}qW�|rN|j|���dS�)z_ Append ``a`` to the list of the virtual ancestors, unless it is already included. TFN)r)���� issubclassr+���)r5���� vancestors�add�j�var���r���r���r+���A��s���� r+���c�����������������sL����st�d��ddj����tjdf�fdd� ������fdd�}d ��|_|S�) zr Factory of decorators turning a function into a generic function dispatching on the given arguments. zNo dispatch args passedz(%s,)z, rw���c����������������s0���|t�|��t�����r,tdt����t�|��|f���dS�)z5Make sure one passes the expected number of argumentszExpected %d arguments, got %d%sN)r~���r2���)Z argumentsZwrong�msg)� dispatch_argsr���r����check[��s����zdispatch_on.<locals>.checkc����������������s����t�t��j�}t���|ks&td����i�����fdd����fdd�����fdd�}���fdd �}����fd d�}tj�d��t|d �|�����|�d� S�)z4Decorator turning a function into a generic functionzUnknown dispatch arguments %sc�����������������sv�����|���dd��t�t���D��}xH�D�]@}x:t|�||�D�]*\}}}t||�r6||j��kr6t||��q6W�q$W�dd��|D��S�)zU Get a list of sets of virtual ancestors for the given types c�������������S���s���g�|�]}g��qS�r���r���)rF����_r���r���r���rG���p��s����zIdispatch_on.<locals>.gen_func_dec.<locals>.vancestors.<locals>.<listcomp>c�������������S���s���g�|�]}t�|��qS�r���)rR���)rF����rar���r���r���rG���u��s����)�ranger~����zipr�����mror+���)�typesZras�types_�tZtype_r����)r����r�����typemapr���r���r����k��s���� z5dispatch_on.<locals>.gen_func_dec.<locals>.vancestorsc�����������������s������|���g�}x�t�|��|����D�]p\}}t|�}|dkrFtd||f���n4|dkrr|\}td||fi��j��dd��}n|j��}|j|dd����qW�|S�)zG Get a list of virtual MROs, one for each type rD���zAmbiguous dispatch for %s: %sr����Nrj���)r����r~����RuntimeError�typer����r+���)r����Zlistsr����ZvasZn_vasr����r����)r����r����r���r���� ancestorsw��s����z4dispatch_on.<locals>.gen_func_dec.<locals>.ancestorsc�����������������s������������fdd�}|S�)zU Decorator to register an implementation for the given types c����������������s&�����t�|��jtjd|�j���|���<�|�S�)Nz in )r���r����operator�ltr ���)r���)r����r����r����r���r���r�������s����z@dispatch_on.<locals>.gen_func_dec.<locals>.register.<locals>.decr���)r����r����)r����r����)r����r����register���s����z3dispatch_on.<locals>.gen_func_dec.<locals>.registerc�����������������s@����|���g�}x.t�j��|�����D�]}|jtdd��|D�����qW�|S�)zI An utility to introspect the dispatch algorithm c�������������s���s���|�]}|j�V��qd�S�)N)r ���)rF���r5���r���r���r���rh������s����zKdispatch_on.<locals>.gen_func_dec.<locals>.dispatch_info.<locals>.<genexpr>)rt����productr+����tuple)r����ZlstZanc)r����r����r���r���� dispatch_info���s ����z8dispatch_on.<locals>.gen_func_dec.<locals>.dispatch_infoc����������������s����t�dd��|�D���}y�|�}W�n�tk r2���Y�nX�|||�S�tj��|����}t|��x(|D�] }�j|�}|d�k rZ|||�S�qZW��||�S�)Nc�������������s���s���|�]}t�|�V��qd�S�)N)r����)rF���r7���r���r���r���rh������s����zGdispatch_on.<locals>.gen_func_dec.<locals>._dispatch.<locals>.<genexpr>)r�����KeyErrorrt���r����rV���r@���)r����r���rB���r����r����combinationsr����)r����r4���r����r���r���� _dispatch���s���� z4dispatch_on.<locals>.gen_func_dec.<locals>._dispatchz#return _f_(%s, %%(shortsignature)s))Z_f_)r�����defaultr����r����r����r����rx���)rR���r���r���rT���r���rr���r/���)r4���Zargsetr����r����r����)r����r�����dispatch_str)r����r4���r����r����r����gen_func_deca��s���� z!dispatch_on.<locals>.gen_func_dec�dispatch_on)r1���r,���r�����ner ���)r����r����r���)r����r����r����r���r����S��s����W r����)N)(r!���Z __future__r����rer<���r���r����rt����collections�__version__�versionr���r ���� namedtupler ���r���r>���r���r ���rX���rN����objectr���ry���r����� contextlibr�����ImportErrorr����r����r���Zinitr~���r���Zn_argsr���r����r����r+���r����r���r���r���r����<module>!���s\��� � &