Mini Shell

Direktori : /usr/lib/python3.6/site-packages/meh/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/meh/__pycache__/dump.cpython-36.opt-1.pyc

3

��\L�@s�ddlZddlZddlZddlZddlZddlmZddlmZye	Z
Wnek
r`eZ
YnXye
ZWnek
r�eZYnXGdd�de�ZGdd�de�ZdS)�N)�PackageInfo)�SafeStrc@sneZdZdZdd�Zedd��Zdd�Zedd	��Zd
d�Z	dd
�Z
ddd�Zdd�Zedd��Z
dd�ZdS)�
ExceptionDumpz�This class represents a traceback and contains several useful methods
       for manipulating a traceback.  In general, clients should not have to
       use this class.  It is mainly for internal use.
    cCsDtj|j�rtj|j�|_n|j|_||_|j|_|j|_i|_dS)aNCreate a new ExceptionDump instance.  Instance attributes:

           :param exc_info: info about the exception provided by Python
           :type exc_info: an instance of the meh.ExceptionInfo class
           :param config_obj: configuration for python-meh
           :type config_obj: an instance of the meh.Config class
        N)�inspectZistraceback�stackZgetinnerframes�conf�type�value�	_dumpHash)�self�exc_infoZ
config_obj�r
�/usr/lib/python3.6/dump.py�__init__2s	zExceptionDump.__init__cCs,|jr$|jr$tj|j|j�dj�SdSdS)Nr�)rr	�	traceback�format_exception_only�strip)rr
r
r�descFszExceptionDump.descc	
s*d�Gdd�dt��dd�}tjdf�fdd�	��fd	d
�}��fdd�}d
d�}y��\}}Wn�k
r~d}d}YnXdj||��}t�}tj�d|d<djtjdj|��djtj��|d<|r�||d<tjd|d<tj�d|d<|r�||d<|�|d<|�r||d<dj|��|d<|S)a
        Returns dictionary containing these items for a bugreport header

        architecture
        cmdline
        component
        executable
        kernel
        package
        release
        other involved packages

        :rtype: dict (string -> string)
        z/etc/system-releasec@seZdZdZdS)z9ExceptionDump._get_environment_info.<locals>.RPMinfoErrorz#Exception for errors in rpm queriesN)�__name__�
__module__�__qualname__�__doc__r
r
r
r�RPMinfoErrorcsrcSsfdddddddddd	d
ddd
ddd�}t�}x,|j�D] }ttj|d�r6|j||�q6Wt|�}|S)z�
            Returns python's command line options

            :return: list of python's command line options
            :rtype: list

            z-dz-3z-Qnewz-Qz-iz-Oz-Bz-sz-Sz-Ez-tz-vz-uz-bz-q)�debugZpy3k_warningZdivision_newZdivision_warningr�interactive�optimize�dont_write_bytecode�no_user_site�no_site�ignore_environmentZtabcheck�verbose�unicode�
bytes_warning�quietN)�set�keys�getattr�sys�flags�add�list)Z
flags_to_opts�ret�flagr
r
r�get_python_optsgs,
z<ExceptionDump._get_environment_info.<locals>.get_python_optsrc	s�ddl}|j�}|jd|�}yt|�}Wn&tk
rN�ddj|���YnXt|djd�|djd�|d	jd�|d
r�d|d
nd|d
jd��}|djd�}t|�}y |j	d�}|d|�j	d�}Wnt
k
r�YnX|d|�}||fS)a|
            Returns package and component names for file (by default for script itself).

            :param file_: filename
            :type file_: string
            :return: tuple containing package info and component name for the file
            :rtype: (PackageInfo, str)
            :raise RPMinfoError: if package and component for the file cannot be found

            rNZ	basenamesz*Cannot get package and component for file z{0}�namezutf-8�version�releaseZepochz%d�0ZarchZ	sourcerpm�-)�rpmZTransactionSetZdbMatch�next�
StopIteration�formatr�decode�len�rindex�
ValueError)	�file_r4ZtsZmi�header�pkg_infoZ	srpm_nameZname_end�	component)rr
r�get_package_and_component�s*
zFExceptionDump._get_environment_info.<locals>.get_package_and_componentcs<y"t�d��}|j�j�SQRXWntk
r6dSXdS)z8Returns release version (according to RELEASE_NAME_FILE)�rNzCannot get release name.)�open�readline�rstrip�IOError)r<)�RELEASE_NAME_FILEr
r�get_release_version�s
z@ExceptionDump._get_environment_info.<locals>.get_release_versionc
s�t�}|js|SxV|jD]L\}}}}}}y$�|�d}dj|�}	|j|	�Wq�k
rbwYqXqWy"��d}dj|�}	|j|	�Wn�k
r�YnX|S)z�
            Returns a set of additional packages whose files appear in
            traceback.

            :rtype: set

            rz){0.name}-{0.version}-{0.release}.{0.arch})r%rr7r*�discard)
rZpackages�_frame�fn�_linenoZ_funcZ_ctx�_idxr>�package)rr@r
r�get_other_packages�s&
z?ExceptionDump._get_environment_info.<locals>.get_other_packagescSs4t�}x(tjj�D]\}}|jdj||��qW|S)z�
            Returns a list of strings containing defined environment
            variables and their values in the following format:

            VARIABLE=VALUE

            :rtype: list

            z{0}={1})r+�os�environ�items�appendr7)r,�keyr	r
r
r�get_environment_variables�szFExceptionDump._get_environment_info.<locals>.get_environment_variablesNz, �Zarchitecturez{0} {1} {2}� Zcmdliner?�
executable�Zkernelr>r1zother involved packages�
rP)	�	Exceptionr(�argv�join�dictrO�unamer7rW)	rr.rGrNrTr>r?Zother_packagesr,r
)rFrr@r�_get_environment_infoQs:#'


z#ExceptionDump._get_environment_infocCs|j�S)N)r_)rr
r
r�environment_infoszExceptionDump.environment_infocCsd|j�}|jdd|jj|jjf�|jdd�|jdk	rZ|jdk	rZ|jtj	|j|j��dj
|�S)Nrz%s %s exception report
�z#Traceback (most recent call last):
r)�
_format_stack�insertr�programName�programVersionrr	�extendrrr\)r�lstr
r
r�__str__szExceptionDump.__str__c	Cs`|js
gSg}xF|jD]<\}}}}}}t|t�r<dj|�}n|}|j||||f�qWtj|�S)Nr)r�
isinstancer+r\rRr�format_list)	rZframesrIrJ�lineno�funcZctxrL�coder
r
rrbs
zExceptionDump._format_stackrrNcCs�dd�}t�}|sg}y6t|�|jkr6d|jt|�<n|d|jj7}|SWntk
rh|d7}|SXd|jjks�d|jjkr�y|d|f7}Wn|d7}YnX|S|d	|jj7}d
|d}�x"|jj�D�]\}}	|jd|jj�r�q�|d
k�r|d|}
n|}
t	d|��rDt	d|�|k�rD|d||
f7}q�t
|	t��r�|d||
f7}d}xT|	D]L}|�s~|d7}nd}||��r�|d|f7}n||j||d|d�7}�qjW|d7}q�t
|	t
��r�||7}||
7}|d7}d}x�|	j�D]�\}
}|�s|d7}nd}t
|
t��s*t
|
t��rD|d7}||
7}|d7}n|d|
f7}||��rl|d|f7}n||j||d|
|d�7}�q�W|d7}q�||	��r�|d||
f7}||	7}|d7}q�|d||
f7}||j|	|d|
|d�7}q�W|S) NcSsvt|t�ptt|t�ptt|t�ptt|t�ptt|t�ptt|td��ptt|t�ptt|t�ptt|t	�ptt
|d�ptt
|d�S)N�	__class__�__dict__)ri�bool�complex�float�int�longtyper�bytes�str�unitype�hasattr)�instancer
r
rZ__isSimpleType-s







z0ExceptionDump._dumpClass.<locals>.__isSimpleTypezAlready dumped (%s instance)
zCannot dump object
rh�__repr__z%s
rYz!%s instance, containing members:
rVrXz_%s__r�.zinstance.%s is not Nonezid(instance.%s)z%s%s: Skipped
z%s%s: [raz, rz%s)�skipListz]
z: {�'z': z%s: )�	parentkeyr|z}
z%s%s: )r�idr
rnr�	TypeErrorrorQ�
startswith�evalrir+�
_dumpClassr]rvrw)rry�levelr~r|Z_ExceptionDump__isSimpleTyper,ZpadrSr	Zcurkey�first�item�k�vr
r
rr�$s�	








 


zExceptionDump._dumpClasscsDg}t�}tjt��}|jr2|j|jddj�x2|jjD]&}ytd|d|�Wq<Yq<Xq<W|jr�|jdd}|d7}yPxJ|jj	�D]<\}}|j
��t�fdd�|jjD��r�q�|d||f7}q�WWnYnXy|d	7}||j
||d
�7}Wn"|d7}|tjd�7}YnXdd�|jjj	�D�}	|d
7}xh|	D]`\}
}y |�}|�rl|d|
|f7}Wn4tk
�r�}
z|d|
|
f7}WYdd}
~
XnX�qFWx�|jjD]�}yDt|ddd��,}|d|f7}x|D]}||7}�q�WWdQRXWn<tk
�rYn(|d|f7}|tjd�7}YnX�q�W|S)a�Dump the local variables and all attributes of a given object.
           The lists of files and attrs to ignore are all taken from a
           Config object instance provided when the ExceptionDump class was
           created.

           obj -- Any Python object.  This object will have all its attributes
                  written out, except for those mentioned in the attrSkipList.
        rarzidSkipList.append(id(obj.%s))Nz%
Local variables in innermost frame:
c3s|]}|j��kVqdS)N)�lower)�.0r�)�lowered_keyr
r�	<genexpr>�sz%ExceptionDump.dump.<locals>.<genexpr>z%s: %s
z

)r|z'
Exception occurred during state dump:
css"|]\}\}}|s||fVqdS)Nr
)r�r/�cbZ
attchmnt_onlyr
r
rr��s
z
Registered callbacks:
z%s:
%s
z%s: Caused error: %s
Zrtzutf-8)�encodingz

%s:
z)
Exception occurred during %s file copy:
���r�)r�copy�localsr�update�f_localsrZattrSkipListr�rQr��anyZ
localSkipListr�r�
format_excZcallbackDictrZZfileListrBrE)r�objZ
idSkipListr,Z	localVarsr��framerSr	Zitems_callbacksZ	item_name�callbackZcallback_ret�excZfnameZfobj�liner
)r�r�dump�sd	
(
zExceptionDump.dumpcCs�ddl}d}|jrdx`dd�|jD�D]:\}}}}t|t�rDdj|�}|dtjj|�||f7}q$Wnd|j|j	f}|j
|jd��j�S)	aQCreate a hash for this traceback object.  This is most suitable for
           searching bug filing systems for duplicates.  The hash is composed
           of the basename of each file in the stack, the method names, and
           the bit of code.  Line numbers and the actual exception message
           itself are left out.
        rNrcSsg|]}|dd��qS)ra�r
)r��fr
r
r�
<listcomp>�sz&ExceptionDump.hash.<locals>.<listcomp>z	%s %s %s
z%s %szutf-8)
�hashlibrrir+r\rO�path�basenamerr	Zsha256�encodeZ	hexdigest)rr��s�filerKrl�textr
r
r�hash�s

 zExceptionDump.hashcCstt|��}||j|�7}|S)z�
        Return the traceback and a text representation of an object.

        :param obj: Any Python object. This object will have all its attributes
                    written out, except for those mentioned in the attrSkipList.

        )rrvr�)rr�r,r
r
r�traceback_and_object_dumps	z'ExceptionDump.traceback_and_object_dump)rrN)rrrrr�propertyrr_r`rhrbr�r�r�r�r
r
r
rr-s4
uSrc@seZdZdZdd�ZdS)�ReverseExceptionDumpaThis class provides an alternate representation of an exception.  In
       this representation, the traceback is printed with the most recent call
       at the top of the stack, and the most generic call at the bottom.  Note
       that this order does not affect the hash at all.
    cCsl|j�}|j�|jdd|jj|jjf�|jdd�|jdk	rb|jdk	rb|jt	j
|j|j��dj|�S)Nrz%s %s exception report
raz$Traceback (most recent call first):
r)rb�reversercrrdrerr	rfrrr\)rrgr
r
rrhszReverseExceptionDump.__str__N)rrrrrhr
r
r
rr�sr�)r�rrOrr(ZmehrZmeh.safe_stringrZlongrt�	NameErrorrsr"rwrv�objectrr�r
r
r
r�<module>s&

e