OwlCyberSecurity - MANAGER
Edit File: pstats.cpython-36.opt-1.pyc
3 � \�g������������������@���sf��d�Z�ddlZddlZddlZddlZddlZddlmZ�dgZG�dd��d�Z G�dd��d�Z dd ��Zd d��Zdd ��Z dd��Zdd��Zdd��Zdd��Zedk�rbddlZyddlZW�n�ek r����Y�nX�G�dd��dej�Zeej�dkr�ejd�ZndZyTee�Zx"ejdd��D�]Zeje���qW�edejd��ej ���edejd��W�n�e!k �r`���Y�nX�dS�)z3Class for printing reports on profiled python code.�����N)� cmp_to_key�Statsc���������������@���s����e�Zd�ZdZdd�dd�Zdd��Zdd ��Zd d��Zdd ��Zdd��Z dBdFdJdNdQdTdWdZd]dbdfdidmdqd!�Z d"d#��Zd$d%��Zd&d'��Z d(d)��Zd*d+��Zd,d-��Zd.d/��Zd0d1��Zd2d3��Zd4d5��Zd6d7��Zdrd9d:�Zd;d<��Zd=d>��ZdS�)sr���a���This class is used for creating reports from data generated by the Profile class. It is a "friend" of that class, and imports data either by direct access to members of Profile class, or by reading in a dictionary that was emitted (via marshal) from the Profile class. The big change from the previous Profiler (in terms of raw functionality) is that an "add()" method has been provided to combine Stats from several distinct profile runs. Both the constructor and the add() method now take arbitrarily many file names as arguments. All the print methods now take an argument that indicates how many lines to print. If the arg is a floating point number between 0 and 1.0, then it is taken as a decimal percentage of the available lines to be printed (e.g., .1 means print 10% of all available lines). If it is an integer, it is taken to mean the number of lines of data that you wish to have printed. The sort_stats() method now processes some additional options (i.e., in addition to the old -1, 0, 1, or 2 that are respectively interpreted as 'stdname', 'calls', 'time', and 'cumulative'). It takes an arbitrary number of quoted strings to select the sort order. For example sort_stats('time', 'name') sorts on the major key of 'internal function time', and on the minor key of 'the name of the function'. Look at the two tables in sort_stats() and get_sort_arg_defs(self) for more examples. All methods return self, so you can string together commands like: Stats('foo', 'goo').strip_dirs().sort_stats('calls'). print_stats(5).print_callers(5) N)�streamc������������G���sF���|pt�j|�_t|�sd�}n|d�}|dd���}|�j|��|�j|���d�S�)Nr�������)�sys�stdoutr����len�init�add)�selfr����args�arg��r����/usr/lib64/python3.6/pstats.py�__init__A���s���� zStats.__init__c�������������C���s����d�|�_�g�|�_d�|�_d|�_d|�_d|�_d|�_t��|�_i�|�_ i�|�_ |�j|��y|�j���W�n8�t k r����td|�jrx|�jd�nd�|�jd����Y�nX�d�S�)Nr���zInvalid timing data %sr�����)�file���)�all_callees�files�fcn_list�total_tt�total_calls� prim_calls�max_name_len�set� top_level�stats� sort_arg_dict� load_stats�get_top_level_stats� Exception�printr���)r���r ���r���r���r���r ���K���s"���� z Stats.initc�������������C���s����|d�kri�|�_�d�S�t|t�rxt|d��}tj|�|�_�W�d�Q�R�X�y"tj|�}tj |j �d�|�}W�n���Y�nX�|g|�_n t|d�r�|j ���|j�|�_�i�|_�|�j�s�td|�j|f���d�S�)N�rbz �create_statsz.Cannot create or construct a %r object from %r)r���� isinstance�str�open�marshal�load�os�stat�timeZctime�st_mtimer����hasattrr$���� TypeError� __class__)r���r ����fZ file_statsr���r���r���r���^���s(���� zStats.load_statsc�������������C���s����x~|�j�j��D�]p\}\}}}}}|��j|7��_|��j|7��_|��j|7��_d|kr\|�jj|��tt|��|�j krtt|��|�_ qW�d�S�)N�jprofiler����profiler)r2���r���r3���) r����itemsr���r���r���r���r ���r����func_std_stringr���)r����func�cc�nc�tt�ct�callersr���r���r���r ���t���s����zStats.get_top_level_statsc�������������G���s����|s|�S�x�t�|�D�]�}t|��t|�kr.t|�}|��j|j7��_|��j|j7��_|��j|j7��_|��j|j7��_x|jD�]}|�jj|��qvW�|�j |j k�r�|j |�_ d�|�_ xJ|jj��D�]<\}}||�jkr�|�j|�}nddddi�f}t ||�|�j|<�q�W�qW�|�S�)Nr���)�reversed�typer���r���r���r���r���r���r ���r���r���r���r4����add_func_stats)r����arg_list�itemr6���r+���Z old_func_statr���r���r���r ���~���s(���� z Stats.addc���������� ���C���s(���t�|d��}tj|�j|��W�dQ�R�X�dS�)z:Write the profile data to a file we know how to load back.�wbN)r'���r(����dumpr���)r����filenamer1���r���r���r���� dump_stats����s����zStats.dump_statsr���� call count�����cumulative time����� file name�����line number����� function name�name/file/liner����primitive call count����� standard name����� internal time)�callsZncallsZcumtime� cumulativer���rC����line�module�nameZnflZpcalls�stdnamer,���Ztottimec�������������C���s����|�j�szi��|�_�}i�}xP|�jj��D�]B\}}|}x4|r`|s8P�||krJd||<�P�|||<�|dd��}q.W�q W�x|D�] }||=�qlW�|�j�S�)z)Expand all abbreviations that are unique.r���Nr���r���)r����sort_arg_dict_defaultr4���)r����dictZbad_list�word�tupZfragmentr���r���r����get_sort_arg_defs����s ���� zStats.get_sort_arg_defsc�������������G���s"��|sd|�_�|�S�t|�dkrFt|d�t�rFddddddddi|d��g}|�j��}f�}d|�_d}x:|D�]2}|||�d��}|��j|||�d��7��_d }qbW�g�}xB|�jj��D�]4\}\}} } }}|j|| | |f|�t |�|f���q�W�|j tt|�j �d ��g��|�_�} x|D�]}| j|d����qW�|�S�) Nr���r���rY���rT���r,���rR���rU���r���z, )�keyr���r���)r���r���r%����intr^���� sort_typer���r4����appendr5����sortr���� TupleComp�compare)r���ZfieldZ sort_arg_defsZ sort_tupleZ connectorr\���Z stats_listr6���r7���r8���r9���r:���r;���r����tupler���r���r���� sort_stats����s2���� zStats.sort_statsc�������������C���s���|�j�r|�j�j���|�S�)N)r����reverse)r���r���r���r���� reverse_order����s���� zStats.reverse_orderc�������������C���s����|�j�}i��|�_�}d}x�|j��D�]�\}\}}}}} t|�} tt| ��|krTtt| ��}i�}x | j��D�]\}} | |t|�<�qbW�| |kr�t|| �|||||f�|| <�q|||||f|| <�qW�|�j}t���|�_}x|D�]}|jt|���q�W�||�_ d�|�_ d�|�_|�S�)Nr���)r���r4����func_strip_pathr���r5���r>���r���r���r ���r���r���r���)r���ZoldstatsZnewstatsr���r6���r7���r8���r9���r:���r;���ZnewfuncZ newcallers�func2�callerZold_topZnew_topr���r���r���� strip_dirs����s.���� zStats.strip_dirsc������� ������C���s|���|�j�r d�S�i��|�_�}xb|�jj��D�]T\}\}}}}}||krBi�||<�x0|j��D�]$\}} ||krdi�||<�| ||�|<�qLW�q W�d�S�)N)r���r���r4���) r���r���r6���r7���r8���r9���r:���r;���rk���rl���r���r���r����calc_callees��s���� zStats.calc_calleesc���������� ���C���s��|}t�|t�rpytj|�}W�n&�tjk rB���|d|�7�}||fS�X�g�}x�|D�]}|jt|��rN|j|��qNW�nzt|�}t�|t �r�d|��ko�dk�n��r�t ||�d��}|d�|��}n2t�|t �r�d|��ko�|k�n��r�|}|d�|��}t|�t|�k�r|dt|�t|�|f�7�}||fS�)Nz# <Invalid regular expression %r> g��������g�������?g�������?r���z6 List reduced from %r to %r due to restriction <%r> )r%���r&����re�compile�error�searchr5���rb���r����floatr`���)r���Zsel�list�msgZnew_listZrexr6����countr���r���r����eval_print_amount��s,���� ""zStats.eval_print_amountc�������������C���s����|�j�}|�jr*|�jd�d���}d|�j�d�}nt|�jj���}d}x|D�]}|�j|||�\}}qBW�t|�}|spd|fS�t||�j d��|t|�j�k�r�d}x(|D�] }tt |��|kr�tt |��}q�W�|d�|fS�)Nz Ordered by: � z! Random listing order was used r���)r���rR���)r���r���ra���rt���r����keysrw���r���r"���r���r5���)r���Zsel_list�widthZ stat_listru���Z selectionrv���r6���r���r���r����get_print_list2��s$���� zStats.get_print_listc�������������G���s����x|�j�D�]}t||�jd��qW�|�j�r0t|�jd��d}x"|�jD�]}t|t|�|�jd��q<W�t||�jdd|�jd��|�j|�jkr�td|�j�d|�jd��td|�j�|�jd��t|�jd��|�j|�\}}|r�|�j ���x|D�]}|�j |��q�W�t|�jd��t|�jd��|�S�) N)r���� ����zfunction calls)�endr���z(%d primitive calls)zin %.3f secondsz )r���r"���r���r����func_get_function_namer���r���r���r{����print_title� print_line)r����amountrC����indentr6���rz���rt���r���r���r����print_statsJ��s(���� zStats.print_statsc�������������G���s~���|�j�|�\}}|rz|�j���|�j|d��x:|D�]2}||�jkrP|�j|||�j|���q,|�j||i���q,W�t|�jd��t|�jd��|�S�)Nz called...)r���)r{���rn����print_call_headingr����print_call_liner"���r���)r���r����rz���rt���r6���r���r���r���� print_calleesa��s���� zStats.print_calleesc������� ������G���sl���|�j�|�\}}|rh|�j|d��x0|D�](}|�j|�\}}}}} |�j||| d��q$W�t|�jd��t|�jd��|�S�)Nzwas called by...z<-)r���)r{���r����r���r����r"���r���) r���r����rz���rt���r6���r7���r8���r9���r:���r;���r���r���r���� print_callersp��s���� zStats.print_callersc������� ������C���sx���t�dj|�|�|�jd��d}x<|�jj��D�].\}}}}}|r(tt|j����} t| t�}P�q(W�|rtt�d|�d�|�jd��d�S�)Nz Function )r���Fr|���z ncalls tottime cumtime) r"����ljustr���r����values�next�iterr%���rf���) r���� name_sizeZcolumn_titleZ subheaderr7���r8���r9���r:���r;����valuer���r���r���r����{��s���� zStats.print_call_heading�->c�������������C���s��t�t|�j|�|�d|�jd��|s2t�|�jd��d�S�t|j���}d}x�|D�]�}t|�}||�} t| t�r�| \} }}} | |kr�d| |f�}n d| f�}d|jdd t |����t |�t | �|f�}|d �}n$d|| t |�j|�d��f�}|d�}t�||�|�|�jd��d}qHW�d�S�) Nr|���)r~���r���)r���r���z%d/%dz%dz%s %s %s %srP���rR���r���z %s(%r) %srF���)r"���r5���r����r����sortedry���r%���rf����rjustr����f8r���)r���r�����sourceZ call_dictZarrowZclistr����r6���rX���r����r8���r7���r9���r:���ZsubstatsZ left_widthr���r���r���r�������s*���� zStats.print_call_linec�������������C���s"���t�dd|�jd��t�d|�jd��d�S�)Nz- ncalls tottime percall cumtime percallr|���)r~���r���zfilename:lineno(function))r���)r"���r���)r���r���r���r���r�������s����zStats.print_titlec�������������C���s����|�j�|�\}}}}}t|�}||kr4|d�t|��}t|jd�d|�jd��tt|�d|�jd��|dkrxtdd|�jd��ntt||��d|�jd��tt|�d|�jd��|dkr�td d|�jd��ntt||��d|�jd��tt|�|�jd��d�S�) N�/� ���r|���)r~���r���r���r}���)r���z z )r���r&���r"���r����r���r����r5���)r���r6���r7���r8���r9���r:���r;����cr���r���r���r�������s����zStats.print_liner����r���r����r����)r����rE���r����r���r����r����)r����rE���r����rF���r����r����)r����rG���r����rF���r����r����)r����rG����rH���r����r����)r����rI����rH���r����r����)r����rI����rJ���r����r����)r����rK����rH���r����r����)r����rI����rL���r����r����)r����rM����rL���r����rH���r����rJ���r����r����r����r����)r����rN���r����r���r����r����)r����rO����rP���r����r����)r����rQ���r����rR���r����r����)r����rS���r����rR���r����r����)r����rS���)r����)�__name__� __module__�__qualname__�__doc__r���r ���r���r ���r ���rD���rZ���r^���rg���ri���rm���rn���rw���r{���r����r����r����r����r����r����r����r���r���r���r���r��� ���sF��� c���������������@���s ���e�Zd�ZdZdd��Zdd��ZdS�)rd���a���This class provides a generic function for comparing any two tuples. Each instance records a list of tuple-indices (from most significant to least significant), and sort direction (ascending or decending) for each tuple-index. The compare functions can then be used as the function argument to the system sort() function when a list of tuples need to be sorted in the instances order.c�������������C���s ���||�_�d�S�)N)�comp_select_list)r���r����r���r���r���r������s����zTupleComp.__init__c�������������C���sB���x<|�j�D�]2\}}||�}||�}||k�r.|�S�||kr|S�qW�dS�)Nr���)r����)r����left�right�index� direction�l�rr���r���r���re������s����zTupleComp.compareN)r����r����r����r����r���re���r���r���r���r���rd������s���rd���c�������������C���s���|�\}}}t�jj|�||fS�)N)r*����path�basename)� func_namerC���rV���rX���r���r���r���rj������s���� rj���c�������������C���s���|�d�S�)NrR���r���)r6���r���r���r���r������s����r���c�������������C���sN���|�d�d��d krB|�d�}|j�d�r<|jd�r<d|dd ���S�|S�nd|��S�d�S�)NrR����~r����<�>z{%s}r���z %s:%d(%s))r����r���r���)� startswith�endswith)r����rX���r���r���r���r5������s����r5���c�������������C���s@���|\}}}}}|�\}}} } }||�||�|| �|| �t�||�fS�)z3Add together all the stats for two profile entries.)�add_callers)�targetr����r7���r8���r9���r:���r;���Zt_ccZt_ncZt_ttZt_ctZ t_callersr���r���r���r>������s����r>���c�������������C���s����i�}x|�j���D�]\}}|||<�qW�xb|j���D�]V\}}||krzt|t�rhtdd��t|||��D���||<�q�||��|7��<�q,|||<�q,W�|S�)z*Combine two caller lists in a single list.c�������������S���s���g�|�]}|d��|d���qS�)r���r���r���)�.0�ir���r���r���� <listcomp>���s����zadd_callers.<locals>.<listcomp>)r4���r%���rf����zip)r����r����Znew_callersr6���rl���r���r���r���r�������s���� r����c�������������C���s"���d}x|�j���D�]}||7�}qW�|S�)z@Sum the caller statistics to get total number of calls received.r���)r����)r;���r8���rT���r���r���r����count_calls���s����r����c�������������C���s���d|��S�)Nz%8.3fr���)�xr���r���r���r������s����r�����__main__c���������������@���s����e�Zd�Zd6dd�Zdd��Zdd��Zdd ��Zd d��Zdd ��Zdd��Z dd��Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��Zdd��Zd d!��Zd"d#��Zd$d%��Zd&d'��Zd(d)��Zd*d+��Zd,d-��Zd.d/��Zd0d1��Zd2d3��Zd4d5��ZdS�)7�ProfileBrowserNc�������������C���s6���t�jj|���d|�_d�|�_tj|�_|d�k r2|�j|��d�S�)Nz% ) �cmd�Cmdr����promptr���r���r���r����do_read)r����profiler���r���r���r�����s����zProfileBrowser.__init__c�������������C���s����|j���}g�}x�|D�]�}y|jt|���wW�n�tk r>���Y�nX�y8t|�}|dksZ|dk�rjtd|�jd��w|j|��wW�n�tk r����Y�nX�|j|��qW�|�jr�t|�j|�|���ntd|�jd��dS�)Nr���r���z#Fraction argument must be in [0, 1])r���zNo statistics object is loaded.) �splitrb���r`���� ValueErrorrs���r"���r���r����getattr)r����fnrV���r���Z processedZtermZfracr���r���r����generic"��s,���� zProfileBrowser.genericc�������������C���sX���t�d|�jd��t�d|�jd��t�d|�jd��t�d|�jd��t�d|�jd��t�d|�jd��d�S�)NzArguments may be:)r���z0* An integer maximum number of entries to print.z:* A decimal fractional number between 0 and 1, controllingz- what fraction of selected entries to print.z8* A regular expression; only entries with function namesz that match it are printed.)r"���r���)r���r���r���r����generic_help:��s����zProfileBrowser.generic_helpc�������������C���sd���|�j�rRy|�j�j|��W�q`�tk rN�}�ztd||f�|�jd��W�Y�d�d�}~X�q`X�ntd|�jd��dS�)Nz$Failed to load statistics for %s: %s)r���zNo statistics object is loaded.r���)r���r ����IOErrorr"���r���)r���rV����er���r���r����do_addB��s����*zProfileBrowser.do_addc�������������C���s���t�d|�jd��d�S�)Nz>Add profile info from given file to current statistics object.)r���)r"���r���)r���r���r���r����help_addK��s����zProfileBrowser.help_addc�������������C���s���|�j�d|�S�)Nr����)r����)r���rV���r���r���r���� do_calleesN��s����zProfileBrowser.do_calleesc�������������C���s���t�d|�jd��|�j���d�S�)Nz6Print callees statistics from the current stat object.)r���)r"���r���r����)r���r���r���r����help_calleesP��s����zProfileBrowser.help_calleesc�������������C���s���|�j�d|�S�)Nr����)r����)r���rV���r���r���r���� do_callersT��s����zProfileBrowser.do_callersc�������������C���s���t�d|�jd��|�j���d�S�)Nz6Print callers statistics from the current stat object.)r���)r"���r���r����)r���r���r���r����help_callersV��s����zProfileBrowser.help_callersc�������������C���s���t�d|�jd��dS�)Nr���)r���r���)r"���r���)r���rV���r���r���r����do_EOFZ��s����zProfileBrowser.do_EOFc�������������C���s���t�d|�jd��d�S�)NzLeave the profile brower.)r���)r"���r���)r���r���r���r����help_EOF]��s����zProfileBrowser.help_EOFc�������������C���s���dS�)Nr���r���)r���rV���r���r���r����do_quit`��s����zProfileBrowser.do_quitc�������������C���s���t�d|�jd��d�S�)NzLeave the profile brower.)r���)r"���r���)r���r���r���r���� help_quitb��s����zProfileBrowser.help_quitc�������������C���s����|r�yt�|�|�_W�nj�tk rF�}�zt|jd�|�jd��d�S�d�}~X�n8�tk r|�}�zt|jjd�||�jd��d�S�d�}~X�nX�|d�|�_ n6t |�j �dkr�|�j d�d��}|�j|��ntd|�jd��dS�) Nr���)r����:z% rR���z1No statistics object is current -- cannot reload.r������)r���r����OSErrorr"���r���r���r!���r0���r����r����r���r����)r���rV����errr���r���r���r����e��s����zProfileBrowser.do_readc�������������C���s ���t�d|�jd��t�d|�jd��d�S�)Nz+Read in profile data from a specified file.)r���z*Without argument, reload the current file.)r"���r���)r���r���r���r���� help_readv��s����zProfileBrowser.help_readc�������������C���s$���|�j�r|�j�j���ntd|�jd��dS�)NzNo statistics object is loaded.)r���r���)r���ri���r"���r���)r���rV���r���r���r���� do_reversez��s����zProfileBrowser.do_reversec�������������C���s���t�d|�jd��d�S�)Nz/Reverse the sort order of the profiling report.)r���)r"���r���)r���r���r���r����help_reverse���s����zProfileBrowser.help_reversec����������������s����|�j�std|�jd��d�S�|�j�j����|rRt��fdd�|j��D���rR|�j�j|j�����n@td|�jd��x0tjj ��D�]"\}}td||d�f�|�jd��qlW�dS�) NzNo statistics object is loaded.)r���c�������������3���s���|�]}|��kV��qd�S�)Nr���)r����r����)�abbrevsr���r���� <genexpr>���s����z)ProfileBrowser.do_sort.<locals>.<genexpr>z/Valid sort keys (unique prefixes are accepted):z%s -- %sr���r���) r���r"���r���r^����allr����rg���r���rZ���r4���)r���rV���r_���r����r���)r����r����do_sort���s���� zProfileBrowser.do_sortc�������������C���s ���t�d|�jd��t�d|�jd��d�S�)Nz.Sort profile data according to specified keys.)r���z3(Typing `sort' without arguments lists valid keys.))r"���r���)r���r���r���r���� help_sort���s����zProfileBrowser.help_sortc����������������s�����fdd�t�jD��S�)Nc����������������s���g�|�]}|j����r|�qS�r���)r����)r�����a)�textr���r���r�������s����z0ProfileBrowser.complete_sort.<locals>.<listcomp>)r���rZ���)r���r����r���r���)r����r���� complete_sort���s����zProfileBrowser.complete_sortc�������������C���s���|�j�d|�S�)Nr����)r����)r���rV���r���r���r����do_stats���s����zProfileBrowser.do_statsc�������������C���s���t�d|�jd��|�j���d�S�)Nz.Print statistics from the current stat object.)r���)r"���r���r����)r���r���r���r���� help_stats���s����zProfileBrowser.help_statsc�������������C���s$���|�j�r|�j�j���ntd|�jd��d�S�)NzNo statistics object is loaded.)r���)r���rm���r"���r���)r���rV���r���r���r����do_strip���s����zProfileBrowser.do_stripc�������������C���s���t�d|�jd��d�S�)Nz<Strip leading path information from filenames in the report.)r���)r"���r���)r���r���r���r���� help_strip���s����zProfileBrowser.help_stripc�������������C���s���t�d|�jd��d�S�)NzShow help for a given command.)r���)r"���r���)r���r���r���r���� help_help���s����zProfileBrowser.help_helpc�������������C���s���|r|S�d�S�)Nr���)r����stoprV���r���r���r����postcmd���s����zProfileBrowser.postcmd)N)r����r����r����r���r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r���r���r���r���r������s4��� r����r���rR���z*Welcome to the profile statistics browser.)r���zGoodbye.)"r����r���r*���r,���r(���ro���� functoolsr����__all__r���rd���rj���r���r5���r>���r����r����r����r����r�����readline�ImportErrorr����r����r����argvZinitprofileZbrowserr����r����r"���r���Zcmdloop�KeyboardInterruptr���r���r���r����<module>���sN������ �