HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/nose/plugins/__pycache__/prof.cpython-37.pyc
B

�fP��@s�dZyddlZddlmZWnek
r8d\ZZYnXddlZddlZddlZddlZddlm	Z	ddl
mZe�d�Z
Gdd	�d	e	�ZdS)
a/This plugin will run tests using the hotshot profiler, which is part
of the standard library. To turn it on, use the ``--with-profile`` option
or set the NOSE_WITH_PROFILE environment variable. Profiler output can be
controlled with the ``--profile-sort`` and ``--profile-restrict`` options,
and the profiler output file may be changed with ``--profile-stats-file``.

See the `hotshot documentation`_ in the standard library documentation for
more details on the various output options.

.. _hotshot documentation: http://docs.python.org/library/hotshot.html
�N)�stats)NN)�Plugin)�tolistznose.pluginsc@s`eZdZdZdZdZdd�Zdd�Zee�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)�ProfilezC
    Use this plugin to run tests using the hotshot profiler. 
    NFcCst|��sdSt�|||�|jddd|�dd�ddd	�|jd
ddd|�d
�dd�|jdddd|�d�dd�dS)z&Register commandline options.
        Nz--profile-sort�store�profile_sortZNOSE_PROFILE_SORTZ
cumulativeZSORTz"Set sort order for profiler output)�action�dest�default�metavar�helpz--profile-stats-file�profile_stats_fileZFILEZNOSE_PROFILE_STATS_FILEz;Profiler stats file; default is a new temp file on each run)rr	rr
rz--profile-restrict�append�profile_restrictZRESTRICTZNOSE_PROFILE_RESTRICTz?Restrict profiler output. See help for pstats.Stats for details)�	availabler�options�
add_option�get)�self�parser�env�r�B/opt/alt/python37/lib/python3.7/site-packages/nose/plugins/prof.pyr!s"

zProfile.optionscCstdk	S)N)�hotshot)�clsrrrr8szProfile.availablecCs&|��sdS|��t�|j�|_dS)z5Create profile stats file and load profiler.
        N)r�
_create_pfilerr�pfile�prof)rrrr�begin<sz
Profile.begincCsf|��sd|_dSt�|||�||_|jr<|j|_d|_nd|_d|_d|_|j	|_
t|j�|_
dS)zConfigure plugin.
        FNT)r�enabledr�	configure�confr
r�clean_stats_file�filenor�sortrr�restrict)rrr!rrrr DszProfile.configurecs2���sdSt�d|��j|f�fdd�	}|S)z6Wrap entire test run in :func:`prof.runcall`.
        Nzpreparing test %scs���|�||�dS)N)rZruncall)�resultr�test)rrr�run_and_profile\sz,Profile.prepareTest.<locals>.run_and_profile)r�log�debugr)rr'r(r)rr�prepareTestVs
zProfile.prepareTestcCs�t�d�|j��t�|j�}|�|j�t	|d�}|rH|j
}||_
ntj}|t_z.|j
rxt�d|j
�|j|j
�n|��Wd|r�||_
n|t_XdS)z Output profiler report.
        zprinting profiler report�streamz"setting profiler restriction to %sN)r)r*r�closer�loadrZ
sort_statsr$�hasattrr,�sys�stdoutr%Zprint_stats)rr,Z
prof_statsZ	compat_25�tmprrr�reportas$


zProfile.reportcCs�|��sdSy|j��Wntk
r.YnX|jr�|jrbyt�|j�Wntk
r`YnXyt�|j	�Wntk
r�YnXdS)z5Clean up stats file, if configured to do so.
        N)
rrr-�AttributeErrorr"r#�os�OSError�unlinkr)rr&rrr�finalizes"zProfile.finalizecCs |jst��\|_|_d|_dS)NT)r�tempfile�mkstempr#r")rrrrr�szProfile._create_pfile)�__name__�
__module__�__qualname__�__doc__rr"rr�classmethodrr r+r3r8rrrrrrsr)r>rr�ImportError�loggingr5r0r9Znose.plugins.baserZ	nose.utilr�	getLoggerr)rrrrr�<module>s